import logging
from
logging.handlers import RotatingFileHandler module_name = "test_module" Rthandler = RotatingFileHandler("/var/lib/test_log/%s.log" % (module_name), maxBytes=10 * 1024 * 1024, backupCount=5) Rthandler.setLevel(logging.INFO) formatter = logging.Formatter("%(asctime)s - %(filename)s[line:%(lineno)d] - %(levelname)s: %(message)s") Rthandler.setFormatter(formatter) logger = logging.getLogger(module_name) logging.basicConfig(level=logging.NOTSET) logger.addHandler(Rthandler)

 

相关文章:

  • 2021-12-11
  • 2022-12-23
  • 2021-10-21
  • 2022-12-23
  • 2022-12-23
  • 2021-07-05
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-11
相关资源
相似解决方案