Nat*_*hes 34
在我的log4j.properties文件中,我将根记录器日志记录级别设置为ERROR.然后对于我特别想要记录的包,就像我的应用程序代码一样,我将日志记录级别设置为INFO或DEBUG.
log4j.rootLogger=ERROR, stdout
log4j.logger.com.initech.tps=DEBUG
log4j.logger.org.hibernate.SQL=INFO
Run Code Online (Sandbox Code Playgroud)
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.
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.
YoK*_*YoK 14
您可以通过更改log4j.properties/log4j.xml文件中的记录器级别来完成此操作.
<level value="off"/>如果要从包中过滤日志,但需要保留记录器配置以供以后使用,则需要设置记录器.您也可以将其设置为最高级别,以便仅在出现错误或致命问题时进行记录.
应将以下条目添加到log4j.xml以关闭来自hibernate和springframework包的日志记录:
<logger name="org.springframework">
<level value="off"/>
</logger>
<logger name="org.hibernate">
<level value="off"/>
</logger>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
31078 次 |
| 最近记录: |