从第三方框架筛选出log4j消息? [英] Filtering out log4j messages from third-party frameworks?

查看:167
本文介绍了从第三方框架筛选出log4j消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何过滤来自外部第三方框架的日志消息?我正在使用Hibernate和Spring框架,我想禁止日志,以便只有我的log4j日志出现。

How do I filter log messages from external third party frameworks? I am using Hibernate and Spring framework and I would like to suppress the logs so that only my log4j logs appears.

推荐答案

在我的log4j.properties文件中,我将根记录器日志级别设置为ERROR。然后对于我特别想要登录的软件包,如我的应用程序代码,我将日志级别设置为INFO或DEBUG。

In my log4j.properties file I set the root logger logging level to ERROR. Then for packages I specifically want to log, like my application code, I set the logging level to INFO or DEBUG.

log4j.rootLogger=ERROR, stdout
log4j.logger.com.initech.tps=DEBUG
log4j.logger.org.hibernate.SQL=INFO

我看到将root logging设置为低的同事然后最终列出他们不想看到的所有内容,这对我来说似乎很落后。我宁愿列出我想记录的内容,而不是所有我不想记录的内容。

I see co-workers who set root logging low and then end up listing everything they don't want to see, that just seems backward to me. I would rather list what I want to log than all the things I don't want to log.

顺便说一句,完全针对第三方组件的注销看起来像是坏主意给我。例如,Spring相对来说比较嘈杂,并且使用WARN来处理我不需要知道的事情,但是如果它记录了一个ERROR条目,我就可以看到它。

BTW turning logging off entirely for a third-party component seems like a bad idea to me. For instance, Spring is relatively noisy and uses WARN for things I really don't need to know about, but if it logs an ERROR entry for something I want to see it.

这篇关于从第三方框架筛选出log4j消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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