Level |
Numeric value |
CRITICAL |
50 |
ERROR |
40 |
WARNING |
30 |
INFO |
20 |
DEBUG |
10 |
NOTSET |
0 |
[root@shuffle-dev py_test]$ vim log.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import logging
FORMAT='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
logging.basicConfig(level=logging.INFO,format=FORMAT)
logger=logging.getLogger(__name__)
logger.info("Start print log")
logger.setLevel(30)
logger.info("start print log")
logger.warning("Something may fail")
[root@shuffle-dev py_test]$ ./log.py
2018-03-04 10:56:10,430 - __main__ - INFO - Start print log
2018-03-04 10:56:10,430 - __main__ - WARNING - Something may fail
网友评论