logging日志介绍

python中操作日志的模块是logging.

基本设置

1
2
3
4
5
6
7
8
9
10
11
import logging

logging.basicConfig(
level=logging.INFO,
format='[%(asctime)s %(name)s %(levelname)s : %(message)s',
datefmt='%Y-%m-%d %H:%M:%S')
logging.getLogger("pytest").setLevel(logging.FATAL)
urllib3.disable_warnings()

LOGGER = logging.getLogger(__name__)