From d303ed3689d7a83d2c4588a830d1ff41153561d7 Mon Sep 17 00:00:00 2001 From: IurNus <464521059@qq.com> Date: Tue, 21 Jun 2022 11:13:46 +0800 Subject: [PATCH] change json dumps parameter to show chinese log content correctly --- logstash/formatter.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/logstash/formatter.py b/logstash/formatter.py index 2b5d618..c449d1b 100644 --- a/logstash/formatter.py +++ b/logstash/formatter.py @@ -80,9 +80,9 @@ def format_exception(cls, exc_info): @classmethod def serialize(cls, message): if sys.version_info < (3, 0): - return json.dumps(message) + return json.dumps(message, ensure_ascii=False) else: - return bytes(json.dumps(message, default=str), 'utf-8') + return bytes(json.dumps(message, default=str, ensure_ascii=False), 'utf-8') class LogstashFormatterVersion0(LogstashFormatterBase): version = 0