当前位置:网站首页>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边栏推荐
- 【案例】定位的运用-淘宝轮播图
- 显示屏DIN 4102-1 Class B1防火测试要求
- SQL series (basic) - Chapter 2 limiting and sorting data
- Explain various hot issues of Technology (SLB, redis, mysql, Kafka, Clickhouse) in detail from the architecture
- EasyExcel的读写操作
- Traps in the explode function in PHP
- What should I do to prepare for the interview algorithm position during school recruitment?
- AITM2-0002 12s或60s垂直燃烧试验
- GCC9.5离线安装
- R language [data management]
猜你喜欢

事项研发工作流全面优化|Erda 2.2 版本如“七”而至

Arcgis\qgis no plug-in loading (no offset) mapbox HD image map

Incentive mechanism of Ethereum eth

Pytorch实战——MNIST数据集手写数字识别

Teach yourself to train pytorch model to Caffe (2)

Haas506 2.0 development tutorial - Alibaba cloud OTA - PAC firmware upgrade (only supports versions above 2.2)

EasyExcel的读写操作

五层网络协议

场景化面试:关于分布式锁的十问十答

Display DIN 4102-1 Class B1 fire test requirements
随机推荐
Recursive query of multi-level menu data
校招期间 准备面试算法岗位 该怎么做?
Clickhouse copy paste multi line SQL statement error
思特奇加入openGauss开源社区,共同推动数据库产业生态发展
selenium 获取dom内属性值的方法
LeetCode_ Hash table_ Difficulties_ 149. Maximum number of points on the line
Chapter 05_ Storage engine
五层网络协议
EN 438-7建筑覆盖物装饰用层压板材产品—CE认证
XML modeling
2022-07-03-cka- latest feedback from fans
Feng Tang's "spring breeze is not as good as you" digital collection, logged into xirang on July 8!
kingbaseES V8R3数据安全案例之---审计记录清除案例
基于 Ingress Controller 在集群外访问 Zadig 自测环境(最佳实践)
Comprehensive optimization of event R & D workflow | Erda version 2.2 comes as "7"
@Validated basic parameter verification, grouping parameter verification and nested parameter verification
Incentive mechanism of Ethereum eth
vant 源码解析 event.ts 事件处理 全局函数 addEventListener详解
木板ISO 5660-1 热量释放速率摸底测试
Using webassembly to operate excel on the browser side