python logger,禁用某些模块的日志

时间:2016-06-07 02:31:37

标签: python logging

是否可以禁用项目中某些模块的日志?我有这个log_config.ini:

[loggers]
keys=root

[handlers]
keys=stream_handler

[formatters]
keys=formatter

[logger_root]
level=DEBUG
handlers=stream_handler

[handler_stream_handler]
class=StreamHandler
level=INFO
formatter=formatter
args=(sys.stderr,)

[formatter_formatter]
format=%(asctime)s %(name)-4s %(levelname)-8s %(message)s

1 个答案:

答案 0 :(得分:0)

[logger_modulename]
handlers=null_handler
propagate=0
qualname=modulename
level=NOTSET

[handler_null_handler]
class=NullHandler
level=NOTSET

不要忘记在null_handlermodulename部分下添加handlerloggers