I want to configure spring logging using log4j.
I want to send all Spring logging to a file and we already use log4j in our application.
How do you do such a thing?
thank you.
I want to configure spring logging using log4j.
I want to send all Spring logging to a file and we already use log4j in our application.
How do you do such a thing?
thank you.
petclinic sample from Spring Distribution uses Log4jConfigListener to configure logging.
you may review the following files
- web.xml: for Log4jConfigListener configuration (it is however disable in the sample)
- log4j.properties: shows an example of logging to a file
Or put a log4j.xml like this to your classpath :
In this example, u trace all the "info" trace of springframeworkCode:<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"> <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender"> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="%p - %C{1}.%M(%L) | %m%n"/> </layout> </appender> <logger name="org.apache"> <level value="WARN"/> </logger> <logger name="servletunit.struts"> <level value="INFO"/> </logger> <logger name="net.sf.hibernate"> <level value="WARN"/> </logger> <logger name="com.opensymphony.oscache"> <level value="WARN"/> </logger> <logger name="org.springframework"> <level value="INFO"/> </logger> <root> <level value="ERROR"/> <appender-ref ref="CONSOLE"/> </root> </log4j:configuration>
Hope it will help u,
Fabien.
I found a solution to my problem.
The problem is cause by to use of commons-logging and Websphere. Websphere use JCL internally and an application have to override websphere's configuration.
Here a link to a complete solution to the problem.
http://www-1.ibm.com/support/docview...id=swg27004610
Excellent timing. I am having a similar problem and was going to post it on Monday. Thanks!
Randy
Thanks for the link to the IBM site. I have tried both methods but neither worked for me.![]()
Which method worked for you?
Option 2 adding org.apache.commons.logging.LogFactory in the META-INF/services directory or
Option 3 commons-logging.properties with classloader set to PARENT_LAST.
> Which method worked for you?
> Option 2 adding org.apache.commons.logging.LogFactory in the META-INF/services directory or
> Option 3 commons-logging.properties with classloader set to PARENT_LAST.
I tried both of these solution and only Option 2 works for me. And you have to put the file org.apache.commons.logging.LogFactory and the services directory in a WEB application.
At first I tried to use an ejb application with no success. In your web application it works like a charm and your application (EAR) will use the JCL setting. Not only the web module as documented in the ibm paper.