This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author janis.slapins
Recipients janis.slapins
Date 2016-03-21.22:17:06
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1458598626.88.0.490041392552.issue26606@psf.upfronthosting.co.za>
In-reply-to
Content
Hi!
Log files are only saved using the system default encoding.
On Windows, this means that the current ANSI code page is used. This may lead to a disaster (exceptions may be thrown due to unmappable characters) if you want to log particular text strings in a foreign language, e.g. those read from a source file in the UTF-8 or UTF-16 encoding, and such strings contain characters not available in your ANSI code page.
I guess this issue does not affect Linux or Mac OSX as they already use the UTF-8 encoding for their system locales.

Actually, the logging module already has the built-in functionality for setting a particular encoding for output files. However, it was not added as a parameter of the baseConfig function (in __init__.py).

I added a patch file with suggested amendments.

I already tested writing logs with those changes applied and files are now saved in the specified encoding which differs from the Windows current ANSI page. For example:
logging.basicConfig(filename=log_path, filemode='w', encoding='utf-8', format='%(message)s', level=logging.INFO)
History
Date User Action Args
2016-03-21 22:17:06janis.slapinssetrecipients: + janis.slapins
2016-03-21 22:17:06janis.slapinssetmessageid: <1458598626.88.0.490041392552.issue26606@psf.upfronthosting.co.za>
2016-03-21 22:17:06janis.slapinslinkissue26606 messages
2016-03-21 22:17:06janis.slapinscreate