Announcement Announcement Module
Collapse
No announcement yet.
Log4j blues, Tomcat 5.030 in a Win Box. Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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

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

    Comment


    • #3
      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.

      Comment


      • #4
        Thank you very much for the quick tips!
        Best regards,
        Gustavo

        Comment


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

          Comment

          Working...
          X