Results 1 to 5 of 5

Thread: Log4j blues, Tomcat 5.030 in a Win Box.

  1. #1
    Join Date
    Dec 2004
    Location
    Buenos Aires, Argentina
    Posts
    73

    Default Log4j blues, Tomcat 5.030 in a Win Box.

    Hi, kind of weird problem here :oops: I will be very happy if this a kind of a newbie problem!

    We are using a FileLogger in Tomcat to have our application log to it's own file. The file has a prefix, a suffix and a timestamp.

    The weird thing in here is some INFO entries go to that file, but others are still in stdout.log. :shock:

    We 'd included in our myapp.xml file a file logger definition:

    Code:
    <Context ....
    <Environment name="config/jdbcConfigLocation" some jndi stuff
    ..
    
    <Logger className="org.apache.catalina.logger.FileLogger" prefix="myapp_" suffix=".log" timestamp="true"/>
    </Context>
    Then, our log4j.properties file, in WEB-INF/classes has the standard settings for stdout.
    Code:
    log4j.rootLogger=INFO, stdout
    log4j.logger.com.acme.myapp=INFO
    Now in the web.xml file we have the regular
    Code:
      <context-param>
        <param-name>log4jConfigLocation</param-name>
        <param-value>/WEB-INF/classes/log4j.properties</param-value>
      </context-param>
    
      <listener>
       <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
      </listener>
    In our beans, we init the logger with a regular
    Code:
    import org.apache.commons.logging.Log;
    import org.apache.commons.logging.LogFactory;
    Log logger = LogFactory.getLog&#40;getClass&#40;&#41;&#41;;
    Some of the problematic classes are not Spring beans, they are created at runtime. They also instantiate the logger using the standard call.

    Any help, or at least an aspirin would be appreciate!

    Cheers,
    Gustavo
    skype: gfaerman

  2. #2
    Join Date
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    1,104

    Default

    Now in the web.xml file we have the regular...
    Code:
    <context-param>
        <param-name>log4jConfigLocation</param-name>
        <param-value>/WEB-INF/classes/log4j.properties</param-value>
      </context-param>
    Not sure if this is related to your problem, but try moving your log4j.properties off the class path:
    Code:
    <context-param>
        <param-name>log4jConfigLocation</param-name>
        <param-value>/WEB-INF/log4j.properties</param-value>
    </context-param>
    See: http://opensource2.atlassian.com/pro...browse/SPR-264

  3. #3
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    I think you have some classpath problems as katentim suggested, especially if you are using clogging. Try to do the standard configuration, where the clogging jars and log4j are found only in common/lib, two configuration files for logging inside commons/classes but no log4j or clogging jar inside shared/lib. Read the manual/Faq from apache tomcat - it explains pretty well the problems with clogging.
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

  4. #4
    Join Date
    Dec 2004
    Location
    Buenos Aires, Argentina
    Posts
    73

    Default

    Thank you very much for the quick tips!
    Best regards,
    Gustavo
    skype: gfaerman

  5. #5
    Join Date
    Sep 2005
    Location
    Newcastle, Australia
    Posts
    61

    Default

    Thanks costin. I too was struggling with log4j and Tomcat when I stumbled on this post.

    The URL for the Tomcat logging faq is http://tomcat.apache.org/faq/logging.html

Similar Threads

  1. Tomcat 5.5, Log4J, Spring
    By KnisterPeter in forum Web
    Replies: 2
    Last Post: Jul 9th, 2006, 01:17 PM
  2. Tomcat WAR, log4j
    By br14n in forum Web
    Replies: 0
    Last Post: Aug 19th, 2005, 12:31 AM
  3. Replies: 4
    Last Post: Apr 6th, 2005, 12:07 PM
  4. Replies: 1
    Last Post: Dec 24th, 2004, 06:42 PM
  5. Stop Spring Logging
    By jgchristopher in forum Container
    Replies: 6
    Last Post: Dec 8th, 2004, 10:32 AM

Posting Permissions

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