当前位置:网站首页>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的奖励机制
- Xlrd common operations
- Comprehensive optimization of event R & D workflow | Erda version 2.2 comes as "7"
- Pytorch实战——MNIST数据集手写数字识别
- 使用Aspect制作全局异常处理类
- Aitm2-0002 12s or 60s vertical combustion test
- Haas506 2.0 development tutorial - Alibaba cloud OTA - PAC firmware upgrade (only supports versions above 2.2)
- int GetMonth( ) const throw( );后面的throw( )什么意思?
- Simple interest mode - lazy type
- 第05章_存储引擎
猜你喜欢

R language learning notes

Enclosed please find. Net Maui's latest learning resources

ArcGIS\QGIS无插件加载(无偏移)MapBox高清影像图

What should I do to prepare for the interview algorithm position during school recruitment?

Parker驱动器维修COMPAX控制器维修CPX0200H

EasyExcel的讀寫操作

Golang (1) | from environmental preparation to quick start

Wood board ISO 5660-1 heat release rate mapping test

leetcode:1755. Sum of subsequences closest to the target value

显示屏DIN 4102-1 Class B1防火测试要求
随机推荐
Generics of TS
Parker驱动器维修COMPAX控制器维修CPX0200H
Access Zadig self-test environment outside the cluster based on ingress controller (best practice)
leetcode:1755. Sum of subsequences closest to the target value
股票开户选择哪家证券公司比较好哪家平台更安全
思特奇加入openGauss开源社区,共同推动数据库产业生态发展
Selenium's method of getting attribute values in DOM
Aitm2-0002 12s or 60s vertical combustion test
Interviewer: will concurrent programming practice meet? (detailed explanation of thread control operation)
AITM2-0002 12s或60s垂直燃烧试验
Explain various hot issues of Technology (SLB, redis, mysql, Kafka, Clickhouse) in detail from the architecture
How to prepare for the algorithm interview and answer the algorithm interview questions
Get JS of the previous day (timestamp conversion)
LeetCode_哈希表_困难_149. 直线上最多的点数
The transformation based on vertx web sstore redis to realize the distributed session of vertx HTTP application
PVC 塑料片BS 476-6 火焰传播性能测定
MMAP
基于vertx-web-sstore-redis的改造实现vertx http应用的分布式session
GCC9.5离线安装
WPF gets the control in the datagridtemplatecolumn of the specified row and column in the DataGrid