From dc3f5f31fe980c1cc54d47513d83fa8d9e94fd87 Mon Sep 17 00:00:00 2001 From: garenchan <1412950785@qq.com> Date: Thu, 20 Sep 2018 11:36:37 +0800 Subject: [PATCH] Specify that the encoding of file handler is utf-8. Fix issue #2503. --- tornado/log.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tornado/log.py b/tornado/log.py index 5948d43ba..1bb6f9571 100644 --- a/tornado/log.py +++ b/tornado/log.py @@ -220,13 +220,15 @@ def enable_pretty_logging(options: Any=None, channel = logging.handlers.RotatingFileHandler( filename=options.log_file_prefix, maxBytes=options.log_file_max_size, - backupCount=options.log_file_num_backups) # type: logging.Handler + backupCount=options.log_file_num_backups, + encoding="utf-8") # type: logging.Handler elif rotate_mode == 'time': channel = logging.handlers.TimedRotatingFileHandler( filename=options.log_file_prefix, when=options.log_rotate_when, interval=options.log_rotate_interval, - backupCount=options.log_file_num_backups) + backupCount=options.log_file_num_backups, + encoding="utf-8") else: error_message = 'The value of log_rotate_mode option should be ' +\ '"size" or "time", not "%s".' % rotate_mode -- 2.47.2