为了调试方便,特意将python的logging模块封装了一下,支持同时向console和file输出,支持日志文件回滚。
(1)myloggingconfig.py
(2)具体使用方法
import logging
logger = logging.getLogger(__name__)
if __name__ == "__main__":
import myloggingconfig
msg = “this is just a test”
logger.info(msg)
如果想动态更改logging的level,可以通过logging.getLogger("").setLevel(level)进行更改。