当前位置:网站首页>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
边栏推荐
- JS common method encapsulation
- SQL common syntax records
- ESP32
- Zhang Lijun: la pénétration de l’incertitude dépend de quatre « invariants»
- postgis 安装地理信息扩展
- "Grain mall" -- Summary and induction
- 第05章_存储引擎
- sql常用语法记录
- Sitge joined the opengauss open source community to jointly promote the ecological development of the database industry
- Dictionary tree simple introductory question (actually blue question?)
猜你喜欢
Clion-MinGW编译后的exe文件添加ico图标
Simple interest mode - evil Chinese style
2.2 basic grammar of R language
Reading and writing operations of easyexcel
Incentive mechanism of Ethereum eth
Display DIN 4102-1 Class B1 fire test requirements
Realize the function of verifying whether the user has completed login when browsing the page
ArcGIS\QGIS无插件加载(无偏移)MapBox高清影像图
EN 438-7建筑覆盖物装饰用层压板材产品—CE认证
MQ----activeMq
随机推荐
Golang (1) | from environmental preparation to quick start
SQL knowledge leak detection
How to prepare for the algorithm interview and answer the algorithm interview questions
AITM2-0002 12s或60s垂直燃烧试验
R语言【数据管理】
Introduction to TS, constructor and its this, inheritance, abstract class and interface
Summary of data analysis steps
PVC 塑料片BS 476-6 火焰传播性能测定
EasyExcel的讀寫操作
selenium 查找b或p标签的内容
Enclosed please find. Net Maui's latest learning resources
The reason why the ncnn converted model on raspberry pie 4B always crashes when called
int GetMonth( ) const throw( ); What does throw () mean?
Using webassembly to operate excel on the browser side
Zhang Lijun: penetrating uncertainty depends on four "invariants"
【日常训练】729. 我的日程安排表 I
Pytorch实战——MNIST数据集手写数字识别
CLion配置visual studio(msvc)和JOM多核编译
Evolution of zhenai microservice underlying framework from open source component encapsulation to self-development
Chap2 steps into the palace of R language