当前位置:网站首页>日志
日志
2022-04-23 05:47:00 【峰爷520】
import logging,sys
# 获取logger的实例
logger = logging.getLogger("testLoger")
# 指定logger的输出形式
formatter = logging.Formatter("%(asctime)s %(levelname)s %(message)s")
# 文件日志,终端日志
file_handler = logging.FileHandler('testLogger.log')
# 文件日志按照指定的格式来写
file_handler.setFormatter(formatter)
console_handler = logging.StreamHandler(sys.stdout)
# 文件日志按照指定的格式来写
console_handler.setFormatter(formatter)
# 把文件日志,终端日志对象添加到日志处理器logger中
logger.addHandler(file_handler)
logger.addHandler(console_handler)
logger.warning("test warning in log")
logger.removeHandler(file_handler)
logger.removeHandler(console_handler)
版权声明
本文为[峰爷520]所创,转载请带上原文链接,感谢
https://blog.csdn.net/weixin_41752427/article/details/81086435
边栏推荐
- Techniques et principes de détection
- MySQL advanced query
- Example of ticket selling with reentrant lock
- JDBC operation transaction
- Generation of verification code
- Introduction to virtualization features
- [leetcode169] most elements
- SQL sorts according to the specified content
- Why does the subscript of the array start from 0 instead of 1?
- [leetcode 459] duplicate substring
猜你喜欢

基于Sentinel+Nacos 对Feign Client 动态添加默认熔断规则

Class loading and classloader understanding
![[leetcode 67] sum of two binary numbers](/img/91/afdd8197ca44ee910e2ee490929df1.png)
[leetcode 67] sum of two binary numbers

SQL -- data filtering and grouping

Understanding and installing MySQL

C language file operation

Addition, deletion, modification and query of MySQL table

Export the articles written in CSDN to PDF format

-- SQL query and return limit rows

Guaba and Computational Geometry
随机推荐
Explain of MySQL optimization
[leetcode 54] spiral matrix
程序設計訓練
[leetcode217] there are duplicate elements
JDBC connection database
3. Continuous integer
Troubleshooting of data deleted and reappeared problems
IO multiplexing of 09 redis
几行代码教你爬取LOL皮肤图片
POJ - 2955 brackets interval DP
破解滑动验证码
Example of ticket selling with reentrant lock
自动控制原理知识点整合归纳(韩敏版)
Generate excel template (drop-down selection, multi-level linkage)
Programming training
Miscellaneous 1
MySQL basic madness theory
2. Average length of words
SQL -- data definition
Gesture recognition research