Razib
Razib

Reputation: 11163

log4j - Configuration, Ignoring the lib/jar Logging

I am working on a java application and I am using log4j for logging. My "log4j.properties" file (in WEB-INF/conf) is here -

log4j.rootLogger=info, stdout

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%p %t %c - %m%n 

log4j.appender.R=org.apache.log4j.RollingFileAppender 
log4j.appender.R.File=C:/billingAutomationService/infotrac20.log
log4j.appender.R.MaxFileSize=30MB 
log4j.appender.R.MaxBackupIndex=10 
log4j.appender.R.layout=org.apache.log4j.PatternLayout 
log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n 

In my application there are a some debug messages with logger.debug("debug message"). But with the configuration I ca not see these debug message in my log file - "stdout.log". To see the debug message in my log file ("stdout.log") I have added the following line in my log4j.properties file -

 log4j.rootLogger=debug,stdout  

But adding this line enables all 'DEBUG' level on my jar/lib along the whole project. I am using a log of spring, hibernate and other jars/libs. This incident makes my log file ("stdout.log") very large even on a single operation. Because a lots of 'DEBUG' message coming from the standard lib/jars which I don't want to debug. Is there any way to turn off the debug message coming form the lib/jars?

Thanks

Upvotes: 1

Views: 1536

Answers (1)

sashwat
sashwat

Reputation: 647

Please check the below thread.

log4j: package-specific logging

Usually you would have a common package starting for all your files, only enable debug for those package names.

Use root logger as warn.

Also.

Specify only some packages to have debug output

Upvotes: 1

Related Questions