本文介绍了请帮我过滤Java应用程序中Apache Log4j的第三方日志记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用第三方jar,它们在Java应用程序的日志文件中附加了自己的日志,我不想在我的日志文件中附加这些第三方日志,因为这会使日志文件非常笨拙和混乱.

I am using Third Party jars which are appending their own logs in my Java Application's Log file , I don't want to append those third party logs in my log file as it makes log file very clumsy and confusing.

我知道这种方法log4j.logger.org.springframework.jdbc.core.JdbcTemplate = OFF可以关闭lo4j.properties中此特定包org.springframework.jdbc.core.JdbcTemplate中的日志记录,但是问题是是我在应用程序中添加了很多这样的jar,因此,要避免为与jar相关的每个程序包手动编写.

I know this method, log4j.logger.org.springframework.jdbc.core.JdbcTemplate=OFF to turn off the logging in this particular package org.springframework.jdbc.core.JdbcTemplate in my lo4j.properties, but the problem is I have many such jars added in my application and hence , want to avoid writing manually for each package associated with the jar.

此外,如果再次添加任何新的jar,我必须将此配置附加到我的log4j.properties文件中.

Also if any new jars are added again I have to append this configuration in my log4j.properties file.

推荐答案

您可以像

log4j.logger.org.springframework=OFF

或者您可以关闭根记录器本身的日志记录,并为您感兴趣的类/程序包启用

or you can turn off logging for the root logger itself and enable it for classes/packages of your interest

log4j.rootLogger=OFF
log4j.logger.com.your-package=DEBUG, yourappender

这将为com.your-package

Log4j简介

这篇关于请帮我过滤Java应用程序中Apache Log4j的第三方日志记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-03 02:40