-
Notifications
You must be signed in to change notification settings - Fork 10
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
我想将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")

MyColorfulDays
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working