1import logging
2
3logging.basicConfig(
4 level=logging.INFO,
5 format="%(asctime)s [%(levelname)s] %(message)s",
6 handlers=[
7 logging.FileHandler("debug.log"),
8 logging.StreamHandler()
9 ]
10)
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")