Python 3 loggingモジュールを使用してログの中の中国語の文字化けしを出力する解決方法
3454 ワード
file handlerの作成時にutf-8として符号化する
python 3でloggingモジュールを使ってログを書いて、中国語の文字化けして、どのように解決しますか?https://segmentfault.com/q/1010000010567904/
logging.handlers — Logging handlers https://docs.python.org/3.6/library/logging.handlers.html
handler = logging.handlers.RotatingFileHandler(LOG_FILE, maxBytes=1024 * 1024, backupCount=5, encoding='utf-8') # handler
2018-01-18 10:52:44,281 - INFO - ���������һ��
2018-01-18 10:52:44,281 - DEBUG - first debug message
2018-01-18 10:53:42,002 - INFO - ���������һ��
2018-01-18 10:53:42,003 - DEBUG - first debug message
2018-01-18 10:54:54,226 - INFO - ���������һ��
2018-01-18 10:54:54,226 - DEBUG - first debug message
2018-01-18 10:58:10,126 - INFO -
2018-01-18 10:58:10,126 - DEBUG - first debug message
2018-01-18 11:28:33,672 - INFO -
2018-01-18 11:28:33,672 - DEBUG - first debug message
python 3でloggingモジュールを使ってログを書いて、中国語の文字化けして、どのように解決しますか?https://segmentfault.com/q/1010000010567904/
logging.handlers — Logging handlers https://docs.python.org/3.6/library/logging.handlers.html