'Use a file to store all messages. The
UTF-8 encoding will be used. Write an informative
message if the file can\'t be created.
@param filename: C{L{string}}'

def setFilename(self, filename, append=True):

    filename = os.path.expanduser(filename)
    filename = os.path.realpath(filename)
    append = os.access(filename, os.F_OK)
    try:
        import codecs
        if append:
            self.__file = codecs.open(filename, 'a', 'utf-8')
        else:
            self.__file = codecs.open(filename, 'w', 'utf-8')
        self._writeIntoFile(_('Starting    Hachoir'))
    except IOError as err:
        if (err.errno == 2):
            self.__file = None
            self.info((_('[Log]    setFilename(%s)    fails:    no    such    file') % filename))
        else:
            raise
