Skip to content

Instantly share code, notes, and snippets.

Created April 4, 2013 16:41
What would you like to do?
Setup logging so that it works with utf-8 log files and ensure stdout is outputting in utf-8
import logging
# Change the default encoding of stdout to utf-8.
# This is effective if the output is piped or redirected.
import sys
# Add a file handler with utf-8 encoding
handler = logging.FileHandler('output.log', 'w',
encoding = 'utf-8')
root_logger = logging.getLogger()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment