File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

WAS commons-logging problem SOLVED (without PARENT_LAST)

 
Anonymous
Ranch Hand
Posts: 18944
  • 0
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I've been seeing a number of people having problems with Jakarta Commons Logging (JCL) and Websphere.
Indeed, Websphere provides a JCL provider which means that by default, if your application uses (or its third party library uses) JCL, it will be logged by JRAS, the Websphere logging infrastructure.
I was myself very frustrated about not being able to have individual log files for my applications, so I started to look into a workaround that would enable my apps to use Log4J as the underlying logging infrastructure.
Ideally, I wanted to:
- use JRAS when used by Websphere classes
- use Log4J when used by my applications
Also, I did not want to change the classloading settings for any applications to PARENT_LAST and to keep the default Websphere settings, as using PARENT_LAST is often source of linkage errors.
The solution I found involves adding a file named org.apache.commons.logging.LogFactory in the META-INF/services directory of your EJB JARs or WARs.
This file would contain the following line (if Log4J is to be used):
org.apache.commons.logging.impl.Log4JLogger
Obviously, you also need to have the following in your classpath:
- log4j.properties (in WEB-INF/classes or at the root of your EJB-JAR)
- commons-logging.jar
- log4j.jar
In the case of WARs, the JCL and log4j libraries need to be in the WEB-INF/lib folder. For EARs, the Class-Path entry of the MANIFEST of your EJB-JARs must contain a relative path to these libraries and the libraries must be packaged in your EAR.
Hope this helps.
[ January 13, 2004: Message edited by: Beno�t d'Oncieu ]
 
Sean Sullivan
Ranch Hand
Posts: 427
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Configuration of Jakarta Commons Logging:
http://jakarta.apache.org/commons/logging/api/org/apache/commons/logging/package-summary.html
 
David Hibbs
Ranch Hand
Posts: 374
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
...and if you want to motivate IBM to fix this so you don't have to do goofy things like change the classloader mode, you can petition them to fix this problem here:
http://www7b.software.ibm.com/webapp/wsdd/wasServlet3
It's item number 241 in the feature request database, which was offline for an astounding length of time but appears to be working again (for now).
 
David Hibbs
Ranch Hand
Posts: 374
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
BTW, did you get this to work for a simple (non-EJB) EAR or WAR project?
I just tried it in WSAD and it didn't work there...
 
Anonymous
Ranch Hand
Posts: 18944
  • 0
  • send pies
  • Quote
  • Report post to moderator
David,
I'm not sure about WASAD as I'm not using it, but it should work the same. If you read carefully my original post, I do explain how to make it work for WAR files.
Cheers,
 
Sean Sullivan
Ranch Hand
Posts: 427
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Integrating Jakarta Commons Logging with IBM WebSphere Application Server V5
http://www-1.ibm.com/support/docview.wss?uid=swg27004610
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic