logging
logging
2023-09-11 14:16:16 时间
import logging
logging.basicConfig(format='%(name)s %(asctime)s %(message)s',level=logging.INFO)
root=logging.getLogger("")
root.setLevel(logging.ERROR)
print(root,root.handlers)
h0=logging.StreamHandler()
h0.setLevel(logging.WARNING)
root.addHandler(h0)
print(root,root.handlers)
for h in root.handlers:
print('root handler: {}, formatter: {}'.format(h,h.formatter))
log1=logging.getLogger('s')
log1.setLevel(logging.ERROR)
h1=logging.FileHandler('c:/uio.log')
h1.setLevel(logging.WARNING)
log1.addHandler(h1)
print(log1,log1.handlers)
log2=logging.getLogger('s.s1')
log2.setLevel(logging.CRITICAL)
h2=logging.FileHandler('c:/bnm.log')
h2.setLevel(logging.WARNING)
log2.addHandler(h2)
print(log2,log2.handlers)
log3=logging.getLogger('s.s1.s2')
log3.setLevel(logging.INFO)
log3.warning('log3')
print(log3,log3.handlers)
import logging
logging.basicConfig(format='%(name)s %(asctime)s %(message)s',level=logging.INFO)
root=logging.getLogger()
root.setLevel(logging.ERROR)
print(root,root.handlers)
h0=logging.StreamHandler()
h0.setLevel(logging.WARNING)
root.addHandler(h0)
print(root,root.handlers)
for h in root.handlers:
print('root handler: {}, formatter: {}'.format(h,h.formatter))
log=logging.getLogger('s')
log.setLevel(logging.ERROR)
h=logging.FileHandler('c:/oo.log')
h.setLevel(logging.WARNING)
print(log,h.formatter)
log.addHandler(h)
print(log,log.handlers)
log1=logging.getLogger('s.s1')
log1.setLevel(logging.CRITICAL)
h1=logging.FileHandler('c:/mm.log')
h1.setLevel(logging.WARNING)
print(log1,h1.formatter)
f1=logging.Formatter('log1 %(name)s %(asctime)s %(message)s')
h1.setFormatter(f1)
print(log1,h1.formatter)
log1.addHandler(h1)
print(log1,log1.handlers)
log2=logging.getLogger('s.s1.s2')
log2.setLevel(logging.INFO)
log2.warning('log2 warning')
print(log2,log2.handlers)
相关文章
- [Node.js] Add Logging to a Node.js Application using Winston
- python中日志logging模块的性能及多进程详解
- logging.basicConfig参数简介
- 日志汇总:logging、logger
- [AWS SAP] Architecture Patterns - Monitoring, Logging and Auditing
- FORCE LOGGING
- logging模块配置笔记
- Java:日志输出JDK Logging、commons-logging、log4j、SLF4J、Logback
- 调试chromium设置 How to enable logging
- 004-log-common-logging,Apache整合日志框架JCL门面框架、JCL+log4j
- Python LOGGING使用方法
- [转]django 日志logging的配置以及处理
- 解决办法:Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Logging