Hi all,

I have an application that writes out its logs in a subfolder of the
user's local data directory. Let's say our user's name is "ßéäöÜ2".

On my Windows XP machine, this logging path turns out to be:

C:\Documents and Settings\ßéäöÜ2\Local Settings\Application Data\MyApp\MyApp.log

My application has a "bootstrap" kind of application that sets up the
application's subfolder and writes out the log config file. Notice
that the user's name contains non-ASCII characters. So, I encode the
path in UTF8 format before writing the log config file. My resulting
log config is (the last line is the most important):

----- BEGIN
[formatters]
keys: normal

[handlers]
keys: rotatingfile

[loggers]
keys: root

[formatter_normal]
format: %(asctime)s %(levelname)s %(module)s: %(message)s

[logger_root]
level: DEBUG
handlers: rotatingfile

[handler_rotatingfile]
class: handlers.RotatingFileHandler
formatter: normal
args: ["C:/Documents and Settings/ßéäöÜ2/Local
Settings/Application Data/MyApp/MyApp.log", "a", 2*1024*1024, 5, None]
----- END

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?

One interesting observation: I did some poking around in the logging
module shipped with Python 2.5. I put in some code in the Python
logging module to force UTF8 decoding of the "filename" argument, the
result of which was interesting: it would end up logging in
"C:\Documents and Settings\ßéäöÜ2\Local Settings\Application
Data\MyApp\MyApp.txt" (not MyApp.log !). I've done a little debugging
and can't immediately figure out why this is happening.

Any help would be greatly appreciated!

Regards,
Mani
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to