This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Websphere and the fly likes WAS commons-logging problem SOLVED (without PARENT_LAST) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » Websphere
Bookmark "WAS commons-logging problem SOLVED (without PARENT_LAST)" Watch "WAS commons-logging problem SOLVED (without PARENT_LAST)" New topic
Author

WAS commons-logging problem SOLVED (without PARENT_LAST)

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
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

Joined: Sep 09, 2001
Posts: 427
Configuration of Jakarta Commons Logging:
http://jakarta.apache.org/commons/logging/api/org/apache/commons/logging/package-summary.html
David Hibbs
Ranch Hand

Joined: Dec 19, 2002
Posts: 374
...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).


"Write beautiful code; then profile that beautiful code and make little bits of it uglier but faster." --The JavaPerformanceTuning.com team, Newsletter 039.
David Hibbs
Ranch Hand

Joined: Dec 19, 2002
Posts: 374
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

Joined: Nov 22, 2008
Posts: 18944
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

Joined: Sep 09, 2001
Posts: 427
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.
 
subject: WAS commons-logging problem SOLVED (without PARENT_LAST)
 
Similar Threads
WAS 5.1 using Struts 1.2.9 - commons-logging issue
commons logging : unable to configure proper logger class
migrating from Jboss4.0 to websphere 6.0
Log issue of Tomcat 6.0.26
RAD6/WAS6 Logging config..