Announcement Announcement Module
Collapse
No announcement yet.
How is Logging configured Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • 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 log4j.properties 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 log4j.properties a spring specific file?
    How can I make spring using my log4j settings/logger?

    Thanks, for any input

    T.

  • #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 log4j.properties 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.

    Comment


    • #3
      Spring is using commons logging (http://jakarta.apache.org/commons/logging/), a thin abstraction layer on top of logging libraries like log4j.

      Log4j (http://logging.apache.org/log4j/docs/) is a powerfull logging library from Apache. It is configured using the log4j.properties 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 log4j.properties in your classpath to properly configure log4j.

      Erwin

      Comment


      • #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?

        Thomas

        Comment


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

          Code:
          log4j.logger=org.springframework=DEBUG
          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 www.ibm.com and search for "log4j was" and you'll find it.

          Comment


          • #6
            I found these links from www.ibm.com

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

            using these search parameters

            +commons-logging +websphere

            Comment


            • #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 commons-logging.properties and log4j.properties 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!

              Thomas

              Comment

              Working...
              X