i have a log4j.properties file that logs my struts application.
my root level is info, and i set the level for org.apache.struts to warn (this supresses all info logs from struts).
log4j.properties:
log4j.rootLogger=info, R
log4j.logger.org.apache.struts=WARN
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=example.log
log4j.appender.R.MaxFileSize=100KB
log4j.appender.R.MaxBackupIndex=1
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n
now i am trying to have the same behaviour using log4j.xml:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<!-- Ausgabe in eine Datei -->
<appender name="datei"
class="org.apache.log4j.RollingFileAppender">
<!-- <param name="Threshold" value="INFO" /> -->
<param name="File" value="kiqn.log" />
<param name="Append" value="true" />
<param name="MaxFileSize" value="100KB" />
<param name="MaxBackupIndex" value="1" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %-5p [%c] %m%n" />
</layout>
</appender>
<logger name="org.apache.struts">
<level value="info"/>
<appender-ref ref="datei"/>
</logger>
<root>
<level value="info" />
<appender-ref ref="datei" />
</root>
I expected this xml file the behave like the properties file, but it doesnt. i get a lot of info logs from org.apache.struts.
Can somebody help ?
-
log4j.properties vs. log4j.xml (4 messages)
- Posted by: sulay ed
- Posted on: June 01 2005 17:10 EDT
Threaded Messages (4)
- log4j.properties vs. log4j.xml by Bruno Kerrien on June 02 2005 04:26 EDT
- log4j.properties vs. log4j.xml by sulay ed on June 02 2005 15:52 EDT
-
Problem with Log4j.xml by JustAUser @ServerSide on July 07 2005 09:34 EDT
- Set additivity="false" by Michael Rimov on March 05 2007 10:04 EST
-
Problem with Log4j.xml by JustAUser @ServerSide on July 07 2005 09:34 EDT
- log4j.properties vs. log4j.xml by sulay ed on June 02 2005 15:52 EDT
-
log4j.properties vs. log4j.xml[ Go to top ]
- Posted by: Bruno Kerrien
- Posted on: June 02 2005 04:26 EDT
- in response to sulay ed
Well, it seems that you assigned the INFO level to your org.apache.struts logger in your XML configuration file, instead of the WARN level that was assigned to it in your properties file. I think it can explain why you have INFO logs now. -
log4j.properties vs. log4j.xml[ Go to top ]
- Posted by: sulay ed
- Posted on: June 02 2005 15:52 EDT
- in response to Bruno Kerrien
sorry, i made a mistake when posting. the level of org.apache.struts is of course "warn" in both files.
still i get infos from struts in the xml version. -
Problem with Log4j.xml[ Go to top ]
- Posted by: JustAUser @ServerSide
- Posted on: July 07 2005 09:34 EDT
- in response to sulay ed
Same here. The root logger seems to over-ride the application log level:
<logger name="com.xyz.abc.logger.MyLogger">
<level value="error"/>
<appender-ref ref="MyAppender"/>
</logger>
<!-- Configure the root appender -->
<root>
<priority value="debug" />
<appender-ref ref="stdout"/>
<appender-ref ref="MyAppender"/>
</root>
I still get DEBUG messages from MyLogger in MyAppender.
Any help, anyone???? It seems to be a bug in log4j1.2.7.
I have seen this working for log4j1.3-alpha.
Any pointers would be appreciated.
Thanks -
Set additivity="false"[ Go to top ]
- Posted by: Michael Rimov
- Posted on: March 05 2007 22:04 EST
- in response to JustAUser @ServerSide
For each level that you wish to "override" a parent (in this case the root level). You need to set the attribute additivity="false" to the logger element. This will give you the desired results.