Note that there are some explanatory texts on larger screens.

plurals
  1. POLog4j: Why is the root logger collecting all log types regardless the configuration?
    text
    copied!<p>I am having problem that even though I specify the level to ERROR in the root tag, the specified appender logs all levels (debug, info, warn) to the file regardless the settings. I am not a log4j expert so any help is appreciated.</p> <p>Here is a bit more info on the subject:</p> <ul> <li>I have checked the classpath for log4j.properties (there is none) except the log4j.xml</li> </ul> <p>here is the log4j.xml file:</p> <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt; &lt;!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"&gt; &lt;log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'&gt; &lt;!-- ============================== --&gt; &lt;!-- Append messages to the console --&gt; &lt;!-- ============================== --&gt; &lt;appender name="console" class="org.apache.log4j.ConsoleAppender"&gt; &lt;param name="Target" value="System.out" /&gt; &lt;layout class="org.apache.log4j.PatternLayout"&gt; &lt;!-- The default pattern: Date Priority [Category] Message\n --&gt; &lt;param name="ConversionPattern" value="[AC - %5p] [%d{ISO8601}] [%t] [%c{1} - %L] %m%n" /&gt; &lt;/layout&gt; &lt;/appender&gt; &lt;appender name="logfile" class="org.apache.log4j.RollingFileAppender"&gt; &lt;param name="File" value="./logs/server.log" /&gt; &lt;param name="MaxFileSize" value="1000KB" /&gt; &lt;param name="MaxBackupIndex" value="2" /&gt; &lt;layout class="org.apache.log4j.PatternLayout"&gt; &lt;param name="ConversionPattern" value="[AC - %-5p] {%d{dd.MM.yyyy - HH.mm.ss}} %m%n" /&gt; &lt;/layout&gt; &lt;/appender&gt; &lt;appender name="payloadAppender" class="org.apache.log4j.RollingFileAppender"&gt; &lt;param name="File" value="./logs/payload.log" /&gt; &lt;param name="MaxFileSize" value="1000KB" /&gt; &lt;param name="MaxBackupIndex" value="10" /&gt; &lt;layout class="org.apache.log4j.PatternLayout"&gt; &lt;param name="ConversionPattern" value="[AC - %-5p] {%d{dd.MM.yyyy - HH.mm.ss}} %m%n" /&gt; &lt;/layout&gt; &lt;/appender&gt; &lt;appender name="errorLog" class="org.apache.log4j.RollingFileAppender"&gt; &lt;param name="File" value="./logs/error.log" /&gt; &lt;param name="MaxFileSize" value="1000KB" /&gt; &lt;param name="MaxBackupIndex" value="10" /&gt; &lt;layout class="org.apache.log4j.PatternLayout"&gt; &lt;param name="ConversionPattern" value="[AC - %-5p] {%d{dd.MM.yyyy - HH.mm.ss}} %m%n" /&gt; &lt;/layout&gt; &lt;/appender&gt; &lt;appender name="traceLog" class="org.apache.log4j.RollingFileAppender"&gt; &lt;param name="File" value="./logs/trace.log" /&gt; &lt;param name="MaxFileSize" value="1000KB" /&gt; &lt;param name="MaxBackupIndex" value="20" /&gt; &lt;layout class="org.apache.log4j.PatternLayout"&gt; &lt;param name="ConversionPattern" value="[AccessControl - %-5p] {%t: %d{dd.MM.yyyy - HH.mm.ss,SSS}} %m%n" /&gt; &lt;/layout&gt; &lt;/appender&gt; &lt;appender name="traceSocketAppender" class="org.apache.log4j.net.SocketAppender"&gt; &lt;param name="remoteHost" value="localhost" /&gt; &lt;param name="port" value="4445" /&gt; &lt;param name="locationInfo" value="true" /&gt; &lt;/appender&gt; &lt;logger name="TraceLogger"&gt; &lt;level value="trace" /&gt; &lt;!-- Set level to trace to activate tracing --&gt; &lt;appender-ref ref="traceLog" /&gt; &lt;/logger&gt; &lt;logger name="org.springframework.ws.server.endpoint.interceptor"&gt; &lt;level value="DEBUG" /&gt; &lt;appender-ref ref="payloadAppender" /&gt; &lt;/logger&gt; &lt;root&gt; &lt;level value="error" /&gt; &lt;appender-ref ref="errorLog" /&gt; &lt;/root&gt; &lt;/log4j:configuration&gt; </code></pre> <p>If I replace the root with another logger, then nothing gets logged at all to the specified appender.</p> <pre class="lang-xml prettyprint-override"><code>&lt;logger name="com.mydomain.logic"&gt; &lt;level value="error" /&gt; &lt;appender-ref ref="errorLog" /&gt; &lt;/logger&gt; </code></pre> <p>... and thank you guys for the hints so far:-)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload