Results 1 to 7 of 7

Thread: How is Logging configured

  1. #1

    Default 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. #2
    Join Date
    Sep 2004
    Location
    Copenhagen, Denmark
    Posts
    113

    Default

    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.
    /Claus

  3. #3
    Join Date
    Sep 2004
    Location
    Leuven, Belgium
    Posts
    1,853

    Default

    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

  4. #4

    Default

    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

  5. #5
    Join Date
    Sep 2004
    Location
    Copenhagen, Denmark
    Posts
    113

    Default

    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.
    /Claus

  6. #6
    Join Date
    Sep 2004
    Location
    Copenhagen, Denmark
    Posts
    113

  7. #7

    Default 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

Similar Threads

  1. Newbie: logging acegi messages
    By cwong in forum Security
    Replies: 2
    Last Post: Sep 28th, 2007, 05:47 PM
  2. Beandoc crashing (on its samples!)
    By aaime in forum Container
    Replies: 17
    Last Post: Oct 7th, 2005, 07:21 AM
  3. Setting logging level to Debug in Spring
    By fineman in forum Container
    Replies: 2
    Last Post: Jul 8th, 2005, 09:31 AM
  4. destroy session upon logging out.Help!
    By mmalonzo in forum Security
    Replies: 1
    Last Post: Mar 2nd, 2005, 03:27 PM
  5. Logging best practices?
    By dekker in forum Container
    Replies: 1
    Last Post: Dec 6th, 2004, 09:12 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •