如何将INFO和DEBUG日志记录消息发送到stdout,如何将更高级别的消息发送到stderr [英] How can INFO and DEBUG logging message be sent to stdout and higher level message to stderr

查看:89
本文介绍了如何将INFO和DEBUG日志记录消息发送到stdout,如何将更高级别的消息发送到stderr的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

python的日志记录模块是否有一种简单的方法可以将具有DEBUG或INFO级别的消息以及具有更高级别的消息发送到不同的流?

Is there an easy way with python's logging module to send messages with a DEBUG or INFO level and the one with a higher level to different streams?

反正是个好主意吗?

推荐答案

不一定是个好主意(看到信息和调试消息与正常输出混合会很混乱!),但可行,因为您可以有多个处理程序对象和每个对象的自定义过滤器,为了选择每个处理程序要处理的日志记录.

Not necessarily a good idea (it could be confusing to see info and debug messages mixed in with normal output!), but feasible, since you can have multiple handler objects and a custom filter for each of them, in order to pick and choose which log records each handler gets to handle.

这篇关于如何将INFO和DEBUG日志记录消息发送到stdout,如何将更高级别的消息发送到stderr的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆