vinay_sajip at yahoo.co.uk
Thu Jun 18 18:15:12 CEST 2009
On Jun 17, 9:05 pm, Mani Ghasemlou <m... at tungle.com> wrote:
> Hi all,
> C:\Documents and Settings\ßéäöÜ2\Local Settings\Application Data\MyApp\MyApp.log
> Now it turns out that the logging module can't find "C:/Documents and
> Settings/ÃŸÃ©Ã¤Ã¶Ãœ2/Local Settings/Application Data/MyApp/MyApp.log"
> specified in the "args" section, and rightfully so because this is an
> encoded string. *There does not seem to be a way for me to specify the
> encoding of the string so that the logging module resolves the proper
> unicode path.* This is my key problem!
> Is there some way to accomplish what I want?
No need to poke about in the source. Here's my script:
#-- log_ufn.py --
logging.error("Holy Cow, Batman!")
and here's my configuration file, adapted from yours:
#-- log_ufn.ini --
format: %(asctime)s %(levelname)s %(module)s: %(message)s
args: (u"C:/Temp/\u00DF\u00E9\u00E4\u00F6\u00DC2/MyApp.log", "a",
2*1024*1024, 5, None)
Note that I specified a Unicode filename, with Unicode escapes for
After I run the script (using ActivePython 18.104.22.168), I get the
# -- Contents of C:\temp\ßéäöÜ2\MyApp.log --
2009-06-18 17:07:30,493 ERROR log_ufn: Holy Cow, Batman!
Which seems to be what one would expect.
More information about the Python-list