当前位置:网站首页>Four components of logger
Four components of logger
2022-07-05 21:30:00 【Nuoyiyou ~】
1. Loggers
2. processor
3. Formatter
4. Filter
class Test_log: def get_logger(self): # The log level :debug info warning error critical # The log level first depends on the logger , Then look at the log processor # Create a logger self.logger = logging.getLogger("logger") self.logger.setLevel("DEBUG") if not self.logger.handlers: # Create processor sh = logging.StreamHandler() fh = logging.FileHandler("{}_log.txt".format(time.strftime("%Y_%m_%d_%H_%M_%S",time.localtime()))) # Create a formatter fmt = logging.Formatter(fmt="%(asctime)s %(filename)s %(levelname)s %(message)s",datefmt="%Y/%m/%d_%H:%M:%S") sh.setFormatter(fmt) fh.setFormatter(fmt) self.logger.addHandler(sh) self.logger.addHandler(fh) return self.logger
边栏推荐
- Establishment of terminal security capability verification environment and penetration test records
- [daily training] 729 My schedule I
- JMeter installation under win7
- 2022-07-03-CKA-粉丝反馈最新情况
- Simple interest mode - lazy type
- EN 438-7建筑覆盖物装饰用层压板材产品—CE认证
- 面试官:并发编程实战会吗?(线程控制操作详解)
- EN 438-7 laminated sheet products for building covering decoration - CE certification
- PVC plastic sheets BS 476-6 determination of flame propagation properties
- Deployment of Jenkins under win7
猜你喜欢
What should I do to prepare for the interview algorithm position during school recruitment?
Five layer network protocol
[case] Application of positioning - Taobao rotation map
R language [data management]
Add ICO icon to clion MinGW compiled EXE file
让开发效率飞速提升的跨端方案
Talk about my fate with some programming languages
Recursive query of multi-level menu data
R语言【数据管理】
ArcGIS\QGIS无插件加载(无偏移)MapBox高清影像图
随机推荐
vant 源码解析之 utils/index.ts 工具函数
Learning notes of statistical learning methods -- Chapter 1 Introduction to statistical learning methods
selenium 获取dom内验证码图片
uni-app 蓝牙通信
Generics of TS
Access Zadig self-test environment outside the cluster based on ingress controller (best practice)
Golang(1)|从环境准备到快速上手
Wood board ISO 5660-1 heat release rate mapping test
Determine the best implementation of horizontal and vertical screens
AITM2-0002 12s或60s垂直燃烧试验
Postgres establish connection and delete records
思特奇加入openGauss开源社区,共同推动数据库产业生态发展
Objects in the list, sorted by a field
ESP32
2022-07-03-cka- latest feedback from fans
CLion配置visual studio(msvc)和JOM多核编译
leetcode:1139. The largest square bounded by 1
Xlrd common operations
Recursive query of multi-level menu data
木板ISO 5660-1 热量释放速率摸底测试