1import logging
2
3rfh = logging.handlers.RotatingFileHandler(
4 filename='foo.log',
5 mode='a',
6 maxBytes=20*1024*1024,
7 backupCount=2,
8 encoding=None,
9 delay=0
10)
11
12logging.basicConfig(
13 level=logging.DEBUG,
14 format="%(asctime)s %(name)-25s %(levelname)-8s %(message)s",
15 datefmt="%y-%m-%d %H:%M:%S",
16 handlers=[
17 rfh
18 ]
19)
20
21logger = logging.getLogger('main')
22
23logger.debug("test")