当前位置:网站首页>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
边栏推荐
- Zhang Lijun: penetrating uncertainty depends on four "invariants"
- ESP32
- EasyExcel的讀寫操作
- How to send samples when applying for BS 476-7 display? Is it the same as the display??
- 2022-07-03-CKA-粉丝反馈最新情况
- Influence of oscilloscope probe on signal source impedance
- WPF gets the control in the datagridtemplatecolumn of the specified row and column in the DataGrid
- Some things make feelings nowhere to put
- Five layer network protocol
- Interviewer: will concurrent programming practice meet? (detailed explanation of thread control operation)
猜你喜欢
Parker驱动器维修COMPAX控制器维修CPX0200H
基于vertx-web-sstore-redis的改造实现vertx http应用的分布式session
SQL knowledge leak detection
CLion配置visual studio(msvc)和JOM多核编译
MQ----activeMq
Explain various hot issues of Technology (SLB, redis, mysql, Kafka, Clickhouse) in detail from the architecture
Introduction of ArcGIS grid resampling method
MySQL InnoDB Architecture Principle
Enclosed please find. Net Maui's latest learning resources
Xlrd common operations
随机推荐
R language learning notes
Five layer network protocol
vant 源码解析 event.ts 事件处理 全局函数 addEventListener详解
Teach yourself to train pytorch model to Caffe (2)
Sophomore personal development summary
Chapter 05_ Storage engine
Xlrd common operations
Get JS of the previous day (timestamp conversion)
【日常训练--腾讯精选50】89. 格雷编码(看题解才会的)
阿里云有奖体验:用PolarDB-X搭建一个高可用系统
水泥胶黏剂BS 476-4 不燃性测试
ArcGIS栅格重采样方法介绍
ESP32
Zhang Lijun: la pénétration de l’incertitude dépend de quatre « invariants»
Pytoch practice -- MNIST dataset handwritten digit recognition
PVC 塑料片BS 476-6 火焰传播性能测定
xlrd常见操作
木板ISO 5660-1 热量释放速率摸底测试
int GetMonth( ) const throw( ); What does throw () mean?
Introduction of ArcGIS grid resampling method