Hi,
I use log4j and he work just fine. A log4j.xml file is in my classpath, i use appender and category... again, it's work just fine for my code or code of other librairy.
But the spring classes continue to flood stdout with message i want to log elsewhere. It's beggin to be anoying.
Offending message : org.springframework.jms : some error.... More generally, all classes of the org.springframework package send message to stdout.
So i put this in my log4j.xml :
<appender name="JMS-ERROR" class="org.apache.log4j.RollingFileAppender">
<param name="File" value="tms.logs.folder/tms.logs.files.prefix-jms-error.log"/>
<param name="Append" value="true"/>
<param name="MaxFileSize" value="1000KB"/>
<param name="MaxBackupIndex" value="2"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="**DVIDEA** %d{dd.MM.yyyy HH:mm:ss} %c %m%n"/>
</layout>
<filter class="org.apache.log4j.varia.LevelRangeFilter">
<param name="LevelMin" value="DEBUG" />
<param name="LevelMax" value="FATAL" />
</filter>
</appender>
<category name="org.springframework.jms" additivity="false">
<appender-ref ref="JMS-ERROR"/>
</category>
It's work with other librairie. Why not spring ?
I do some research, and it's appeart that Spring use common-logging, and not log4j. It's that a possible cause ? Any workaround ?
I have try to add a log4jConfigurationListener to my web.xml. he's working but i stil dont have any control over the spring error message.
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>classpath:log4j.xml</param-value>
</context-param>
<context-param>
<param-name>log4jRefreshInterval</param-name>
<param-value>10000</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
Edit :
Some more info :
- i use Tomcat 5.5
- a log4j.property ( old log4j config ) is still present for historical reason. I'v try to remove it => no change.
EDIT 2 : I use the following workaround, but i'm not happy with it : it's not configurable
java.util.logging.Logger springLogger = Logger.getLogger("org.springframework.jms");
springLogger.setLevel(Level.OFF);