Home:ALL Converter>Logging from Spring using Log4j under WebSphere

Logging from Spring using Log4j under WebSphere

Ask Time:2013-11-11T21:35:24         Author:Danubian Sailor

Json Formatter

I'm using log4j in my WebSphere application. I need to debug class org.springframework.ejb.access.AbstractRemoteSlsbInvokerInterceptor, so I've created logger in my log4j.xml file:

<logger name="org.springframework">
    <level value="INFO" />
</logger>

<logger name="org.springframework.ejb.access">
    <level value="TRACE" />
</logger>

I've created also commons-logging.properties in src/main/resources of the web project (in maven):

org.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JLogger

However, Spring is NOT logging using log4j. I see no springframework logs in my debug file, but I can see some of them (INFO) in the console. Therefore I assume, the apache commons logging used by Spring is NOT logging using log4j.

Is it possible (and how) to redirect logging used by Spring to Log4j engine under WebSphere?

WebSphere 7.0, Spring 3.1.2, log4j 1.2.6, commons-logging 1.1 provided in shared library.

Author:Danubian Sailor,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/19907711/logging-from-spring-using-log4j-under-websphere
jodel :

Try the following:\n\n\nConsider using slf4j for your logging. Add log4j to your dependencies in maven.\nAdd jcl-over-slf4j to your maven dependencies. This redirectes each request from jcl to slf4j.\nSearch for the dependency commons-logging inside your maven dependencies. Exclude it, so it does not get to your deployment archive.\nDelete the \"commons-logging.properties\"-file.\n\n\nI hope that everythings works out fine now.",
2013-11-11T14:01:56
yy