Announcement Announcement Module
Collapse
No announcement yet.
WSAD / Spring / Log4j Problem Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • WSAD / Spring / Log4j Problem

    Hi guys,

    I have seen many posts on this issues, well basically how do we enable logging in websphere server 5 and above for Spring apps.

    I have given it a try for days now and haven't got it working, I would like to know if anyone of you ever got it working in WAS

    - Add a commons-logging.properties file in your web application class
    path (e.g. under /WEB-INF/classes/ ) with :
    - Add commons-logging.jar and log4j.jar in your web app classpath
    (e.g. under /WEB-INF/lib/ )
    - Set "Classloader Mode" attribute to "PARENT_LAST"


    Interestingly my Junit tests seems to pick up the correct log4j.proerties file, but it fails to log in web environment, I'm sure it is some classloading issues

    http://www-1.ibm.com/support/docview...id=swg27004610

    I have tried all of this but running out of patience now, let me know your experience on this one.

  • #2
    Probably a classloader issue

    I got the same issue some times ago. I followed the IBM guide but it didnít work.
    After looking at the "lib" and "lib/ext" to find out if a shared library was messing up I figured that there was a file "ws-commons-logging.jar" in the "lib" directory of the server runtime. I deleted it (but renaming to something different than *.jar should work too) then I got log4j to work properly.
    The web server seems to read the "commons-logging.properties" from this IBM shared JAR and ignore the one in the "commons-logging.jar" you put in your application.

    Hope this helps.

    Comment


    • #3
      We got it working with "services" folder in META-INF folder of the webapp.
      This services folder has the only file named "org.apache.commons.logging.LogFactory"
      And the contents of this file is the only string
      Code:
      org.apache.commons.logging.impl.Log4jFactory
      This intrusction can be found on IBM site somewhere. Or you can drop me a message, and i'll send this pdf file to you

      Comment


      • #4
        Look for a jar file called ws-commons.jar

        in here for RAD 6

        C:\Program Files\IBM\Rational\SDP\6.0\runtimes\base_v6\lib

        and delete it. Make sure you have the server stopped at the time.

        If you are using WSAD 5 look in the equivalent runtimes directory for the WAS 5.1 server and delete the aforementioned file.

        It's all caused by stuff like Spring and Hibernate using commons-logging, and IBM implement their own logger that jumps in before LOG4J.

        Comment


        • #5
          Wow that's awesome that you figured this out. I'd given up on it, even after speaking to IBM tech support.

          I found that the instructions that IBM provides do work for certain versions of 6.0.x but, as you apply fix packs to the app server, the IBM instructions sometimes work and sometimes don't.

          Could you (Paul Newport) tell us what version(s) your fix worked on?

          I think I got logging working for WebSphere 6.0.2.9, by nuking the ws-commons-logging.jar from <Rational6.0-install-dir>\runtimes\base_v6\lib add adding the Jakarta commons-logging.jar back into the /WEB-INF/lib of my Spring (2.0rc3) app. YEAH!
          Last edited by pea1; Aug 25th, 2006, 07:53 AM.

          Comment


          • #6
            Got it working!

            Well it is for sure classloader issue in WSAD 5.1.2 (WAS Test environment 5.1)

            Following trick worked for me

            1. For your application set following classloader policy
            Classloadermode PARENT_LAST
            WAR classlloader policy APPLICATION

            2. Download xerces binaries from following site
            http://www.apache.org/dist/xml/xerces-j/binaries/
            Copy these two jars to WEB-INF/lib of your application

            xml-apis.jar
            xercesImpl.jar

            (If i don't do this, I get XML exceptions while spring trys to read the config files)

            3. Make sure you have log4j.properties in WEB-INF/classes


            Restart and test it out, I still need to test this out in our production WAS instance, will update the thread with my findings

            Thanks to all of you for your prompt reply.

            Comment

            Working...
            X