Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Please help me Filtering out Third Party Logging for Apache Log4j in my Java Application

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.

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.

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

like image 424
yash ahuja Avatar asked Apr 11 '26 08:04

yash ahuja


1 Answers

you can takedown whole librabries as in

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

this will enable DEBUG logging for all subpackages and classes under com.your-package

look at Logging Hierarchies at Log4j intro

like image 138
mzzzzb Avatar answered Apr 12 '26 20:04

mzzzzb



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!