christopher
christopher

Reputation: 27356

Log4j displaying incorrect logging levels

My logger seems to be working quite nicely, but recently it's been displaying DEBUG messages. I'm not completely sure why, because I've not changed anything.

This is the contents of my log4j.properties file:

# Set root logger level to appropriate level and its appender to A1, R
log4j.rootLogger=INFO, A1, R
# A1 is set to be a ConsoleAppender.
log4j.appender.A1=org.apache.log4j.ConsoleAppender

# A1 uses PatternLayout.
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%d %-5p [%c] %m%n

# R is set to be a rolling log file appender
log4j.appender.R=org.apache.log4j.DailyRollingFileAppender
log4j.appender.R.File=${catalina.home}/logs/evepromote.log

# R also uses PatternLayout.
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%d %-5p [%c] %m%n

I only want to display INFO messages, and I thought I had done that with log4j.rootLogger. Can anyone see a reason why DEBUG messages are being displayed?

EDIT

First DEBUG line is from spring, which is.. confusing really. I've been using Spring from the start and it't not done this before:

2014-01-08 10:16:26,742 DEBUG [org.springframework.web.context.support.StandardServletEnvironment] Initializing new StandardServletEnvironment

Output from Log4j Initialisation

log4j: Using URL [file:/C:/IntelliJIdea/IntelliJIdea/system/tomcat/Unnamed_EvePromote/work/Catalina/localhost/evepromote/WEB-INF/classes/log4j.xml] for automatic log4j configuration.
log4j: Preferred configurator class: org.apache.log4j.xml.DOMConfigurator
log4j: System property is :null
log4j: Standard DocumentBuilderFactory search succeded.
log4j: DocumentBuilderFactory is:    com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl
log4j: debug attribute= "null".
log4j: Ignoring debug attribute.
log4j: reset attribute= "false".
log4j: Threshold ="null".
log4j: Level value for root is  [debug].
log4j: root level set to DEBUG
log4j: Class name: [org.apache.log4j.ConsoleAppender]
log4j: Setting property [target] to [System.out].
log4j: Parsing layout of class: "org.apache.log4j.PatternLayout"
log4j: Setting property [conversionPattern] to [%d %-5p [%c] %m%n].
log4j: Adding appender named [console] to category [root].

What's really jumping out at me here is the fact that it's looking for a .xml file by default, when I have a .properties file.

Upvotes: 0

Views: 1771

Answers (2)

Isaac
Isaac

Reputation: 16736

Log4J, by default, will look for a log4j.xml file first, and only if it can't find it - will look for log4j.properties. You can override this by setting the log4j.configuration system property to point at the exact configuration file you're interested in.

Upvotes: 2

Alex Suo
Alex Suo

Reputation: 3129

This is mostly because some 3rd party library you load up changed the global/logger level settings to enable DEBUG messages.

Check the first line of DEBUG information to see where it's initiated may give you some idea of which library is causing that; otherwise, try check if there is any newly added libraries/dependencies in your project.

Upvotes: 0

Related Questions