Announcement Announcement Module
No announcement yet.
How is Logging configured Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • How is Logging configured

    Hi, I'm using spring on my J2EE app running on WAS. I already use Log4j in my project and defined appenders and a layout for the root logger.

    I want Spring also to use this logger or that springs child is derived from my root logger. In a test project outside the container I've used in the classpath and I was able to modify the logging behaviour of spring. This is however something I've found here in the forum.
    When I look at the doc, I cannot see a mere line of how logging is working in spring and how to configure it.

    My questions are:

    is a spring specific file?
    How can I make spring using my log4j settings/logger?

    Thanks, for any input


  • #2
    Spring is using commons-logging where you should be able to use either JDK4 og Log4j as the actual logger.

    Spring does not distribute a file in any of it's .jar file.

    Your problem is WAS it's troublesome to configure it so commons-logging works with log4j.

    6 months ago I had the same trouble I found a 10-15 page .pdf document from IBM's site how to configure commons logging in WAS. It sure wasn't easy.


    • #3
      Spring is using commons logging (, a thin abstraction layer on top of logging libraries like log4j.

      Log4j ( is a powerfull logging library from Apache. It is configured using the file (so that file in essense has nothing to do with Spring).

      So to make Spring use log4j, just make sure the log4j.jar is in your classpath. Commons logging will pick up on it and will start using log4j to do the actual logging. Also make sure you have in your classpath to properly configure log4j.



      • #4
        Hi, thnaks for your replies!

        Sorry that I did not point out that I already know that. In fact I deploy commons-logging.jar and log4j.jar as utility JARs. So Spring picks up log4j as actual implementation - that's not my problem.

        My problem is how could I make spring using my configuration for Log4j. As i said there is no documentation about that.

        A possible way would be maybe: to use system properties.
        I'm also interested in this WAS document.
        Do you know whether when configuring a root logger this logger is
        configured JVM wide or only thread wide?



        • #5
          So what you actually want is to put in your own

          and have it logged out to your logfile?

          Yeah it's a pain to configure in WAS. I gave it up at the time.

          In the .pdf document there is something about selection of classloading strategy, where to place the .jar files in either WEB-INF/lib og as utility jars in and defined in the MANIFEST.MF that is in your .ear file so logging also works from EJB's if you use this.

          I don't have the .pdf anymore as I have switched to a new computer and haven't been on that project for 6+ months.

          Just go to and search for "log4j was" and you'll find it.


          • #6
            I found these links from


            using these search parameters

            +commons-logging +websphere


            • #7
              Found a solution

              Hi, thanks, for posting the docs. Actually I'm using WAS 6 and with all info fragments I could pick up I figured out a solution:

              Fact: WAS uses also commons logging, so you have to init log4j/commons before WAS does.

              Measures: I had to place and in a dir called properties (also exists in WAS 5 I think). AND I changed the classloading strategy of my EAR to PARENT LAST (or similar).

              Now I have one logfile and everything gets logged there...
              Really a PITA withs WAS I have to admit!