Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Log4j | Updating the Log Level for the Appender

Tags:

java

log4j

My log4j.properties file -

log4j.rootLogger=INFO, stdout

# =============== console output appender =====================
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=[%d{HH:mm:ss}] %5p: [%c{1}] %m%n

# =================== common logging =========================
# The log level for all classes that are not configured below.
log4j.logger.petascope=INFO

log4j.logger.petascope.wcps=DEBUG
log4j.logger.petascope.wcst=DEBUG
log4j.logger.petascope.wcs=DEBUG
log4j.logger.petascope.wcs2=TRACE

I want to display even DEBUG and TRACE messages on stdout, so I changed the following line

   log4j.rootLogger=TRACE, stdout

But I don't see any changes when I view the logs echoes on Tomcat Console, I still see only INFO, WARN ... messages.

like image 430
Vaibhav Bajpai Avatar asked Oct 26 '22 03:10

Vaibhav Bajpai


1 Answers

Well, even if you have your root logger as TRACE, your log4j.logger.petascope (pointing to INFO) will override the default root logger's TRACE for petascope.* packages, which is the reason you are not seeing any DEBUG and TRACE.

To keep things simple, try this... set the root logger to trace:-

log4j.rootLogger=TRACE, stdout

Then, comment out the following lines:-

#log4j.logger.petascope=INFO
#log4j.logger.petascope.wcps=DEBUG
#log4j.logger.petascope.wcst=DEBUG
#log4j.logger.petascope.wcs=DEBUG
#log4j.logger.petascope.wcs2=TRACE

Let me know if that works for you.

like image 156
limc Avatar answered Nov 08 '22 11:11

limc