当前位置:网站首页>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
边栏推荐
- 【案例】定位的运用-淘宝轮播图
- Ethereum ETH的奖励机制
- R语言【数据管理】
- 基于 Ingress Controller 在集群外访问 Zadig 自测环境(最佳实践)
- LeetCode_ Hash table_ Difficulties_ 149. Maximum number of points on the line
- ESP32
- CLion配置visual studio(msvc)和JOM多核编译
- ArcGIS栅格重采样方法介绍
- Talk about my fate with some programming languages
- Explain various hot issues of Technology (SLB, redis, mysql, Kafka, Clickhouse) in detail from the architecture
猜你喜欢
EasyExcel的讀寫操作
阿里云有奖体验:用PolarDB-X搭建一个高可用系统
MySQL 千万数据量深分页优化, 拒绝线上故障!
Deployment of Jenkins under win7
The transformation based on vertx web sstore redis to realize the distributed session of vertx HTTP application
Five layer network protocol
显示器要申请BS 476-7 怎么送样?跟显示屏一样吗??
Display DIN 4102-1 Class B1 fire test requirements
"Grain mall" -- Summary and induction
Golang (1) | from environmental preparation to quick start
随机推荐
Utils/index TS tool function
postgres 建立连接并删除记录
有些事情让感情无处安放
Wood board ISO 5660-1 heat release rate mapping test
Environment configuration problem record
Making global exception handling classes with aspect
Learning notes of statistical learning methods -- Chapter 1 Introduction to statistical learning methods
木板ISO 5660-1 热量释放速率摸底测试
Parker driver maintenance COMPAX controller maintenance cpx0200h
【案例】元素的显示与隐藏的运用--元素遮罩
Recursive query of multi-level menu data
Feng Tang's "spring breeze is not as good as you" digital collection, logged into xirang on July 8!
100 cases of shell programming
PostGIS installation geographic information extension
Sorting out the problems encountered in MySQL built by pycharm connecting virtual machines
Problems encountered in office--
Talk about my fate with some programming languages
股票开户选择哪家证券公司比较好哪家平台更安全
Five layer network protocol
selenium 获取dom内验证码图片