Skip to content

输出为文件message不显示 #1

@yllgl

Description

@yllgl

我想将log同时输出到控制台和文件中,但是文件中的message不显示。
以下是我的代码:
STRING_FORMAT = '''{ "Levelname": "levelname", "Filename": "filename", "Lineno": "lineno", "Asctime": "asctime", "Message": "%(message)s" }''' root = logging.getLogger("bb.log") root.setLevel(logging.DEBUG) formatter = JsonFormatter(STRING_FORMAT) sh = logging.StreamHandler() sh.setFormatter(formatter) sh.setLevel(logging.DEBUG) th=logging.FileHandler("bb.log") th.setFormatter(formatter) th.setLevel(logging.DEBUG) root.addHandler(sh) root.addHandler(th) root.info("test format")
image

Metadata

Metadata

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions