我有一个金字塔应用程序,希望日志输出到stderr和stdout。stdout的级别为“INFO”及以下,stderr的级别为“WARN”及更高。如何更改我的ini文件实现这一功能?
目前我是这样记录日志的,这是否被认为是正确的方式?
log = logger.getLogger(__name__) log.info("更新 ...") log.error("MAYDAY MAYDAY... BOOM!!!")
目前我正在使用默认的记录日志方式,如下所示。
[loggers] keys = root, app [handlers] keys = console [formatters] keys = generic
[logger_root] level = WARN handlers = console [logger_app] level = WARN handlers = qualname = app [handler_console] class = StreamHandler args = (sys.stderr,) 85 level = NOTSET formatter = generic
[formatter_generic] format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s