1

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.

Danubian Sailor
  • 1
  • 38
  • 145
  • 223
  • @Dropout I'm using log4j, spring fora suggest that spring logs should go through the log4j if properly configured, but in my case it doesn't happen. – Danubian Sailor Nov 11 '13 at 13:43
  • 1
    check this post on SO http://stackoverflow.com/questions/19753953/logging-in-spring-framework-flow-and-configuration – arajashe Nov 11 '13 at 14:04
  • The recipe is simple: don't use shared libraries unless you need troubles. – ᄂ ᄀ Nov 11 '13 at 18:06

2 Answers2

1

Try the following:

  1. Consider using slf4j for your logging. Add log4j to your dependencies in maven.
  2. Add jcl-over-slf4j to your maven dependencies. This redirectes each request from jcl to slf4j.
  3. Search for the dependency commons-logging inside your maven dependencies. Exclude it, so it does not get to your deployment archive.
  4. Delete the "commons-logging.properties"-file.

I hope that everythings works out fine now.

jodel
  • 23
  • 4
  • Moving to slf4j would be possible, but require consultations with the team leader. However, I can't fully remove org.apache.commons.logging libraries, since they are the part of the WebSphere runtime. – Danubian Sailor Nov 11 '13 at 14:09
1

This technique to route JCL (including Spring) logging to your log4j configuration still works.

For the apps where we also have slf4j already (the Spring WebFlow ones), that can also be routed to your log4j configuration.

However, if you just want to see the Spring log information, you can increase its level of logging to WebSphere's own logs (SystemOut.log) via the console's Troubleshooting > Logs and Trace > server-name > Change log level details.

Add something like : org.springframework.ejb.access.*=fine (colon is the separator).

I don't know what the exact WAS levels correspond to, but fine, finer, and finest are listed under the "Trace" levels if you expand the Components and Groups area just to see what is available.

(I don't think it matters that your particular Spring package is not listed under there, BTW. I believe it should still successfully control your logging.)

Community
  • 1
  • 1
dbreaux
  • 4,982
  • 1
  • 25
  • 64