1-3 配置文件方式

最后更新于:2022-04-02 07:44:56

~~~ #!/usr/bin/env python # coding: utf-8 # @Time : 2021/11/11 15:39 # @Author : YD # @Email : dinhe_1985@126.com # @File : 6-5.py # @Software: PyCharm # @Blog : www.noteshare.cn import logging # 导入模块 import logging.config # 加载配置文件 logging.config.fileConfig('logging.conf') # 设置记录器名称 rootLogger = logging.getLogger('root') rootLogger.debug('this is root debug log') # 设置记录器名称 logger = logging.getLogger('applog') logger.debug('This is applog debug log') # 通过logger.exception捕获程序异常 a = 'abc' try: int(a) except Exception as e: # logger.error(e)记录信息不完整 logger.exception(e) ~~~
';