import logging
from logging.handlers importRotatingFileHandler
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)