Announcement Announcement Module
Collapse
No announcement yet.
Spring Framework DEBUG logging with Log4J Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring Framework DEBUG logging with Log4J

    How do I get debug log statements from Spring using Log4j? This is my properties file:

    Code:
    log4j.rootLogger=DEBUG, stdout
    
    log4j.appender.stdout=org.apache.log4j.ConsoleAppender
    log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
    log4j.appender.stdout.layout.ConversionPattern=%d{HH:mm:ss} %5p [%t] (%F:%L) - %m%n
    
    log4j.appender.stdout.org.springframework=DEBUG
    I've tried everything I can think of, even added a listener for Log4jConfigListener to my web.xml no avail.

    Any help appreciated.

  • #2
    Toward the bottom of http://forum.springframework.org/showthread.php?t=11551 may give some clues.
    Last edited by robyn; May 14th, 2006, 05:24 PM.

    Comment


    • #3
      I did. That's the only reason I tried to "enable" it. Everything else logs great in Log4J, but my Spring stuff in only INFO level.

      AND I have a comma after my debug in the first line.

      Comment


      • #4
        Just wondering if your logger setting is right, as I think it should look more like this (I'm not familar with every aspect of Log4J, so you could also be right):

        Code:
        log4j.logger.org.springframework.aop.framework.autoproxy=DEBUG, stdout
        Your other code that logs OK via Log4J, is it using Log4J directly or via Commons Logging? If via Commons Logging, it is certainly strange. Could you include a few lines of Spring logging output, so we can see the conversion pattern - perhaps it's going via the JDK logger rather than Log4J at the INFO level, suggesting Commons Logging isn't detecting Log4J. This post might help: http://jakarta.apache.org/commons/logging/guide.html.

        Comment


        • #5
          Originally posted by Ben Alex
          Your other code that logs OK via Log4J, is it using Log4J directly or via Commons Logging? If via Commons Logging, it is certainly strange. Could you include a few lines of Spring logging output, so we can see the conversion pattern - perhaps it's going via the JDK logger rather than Log4J at the INFO level, suggesting Commons Logging isn't detecting Log4J.
          I think that's EXACTLY what's happening.

          Code:
          INFO: Published WebApplicationContext of servlet 'action' for module '' as ServletContext attribute with name [org.springfram
          ework.web.struts.ContextLoaderPlugIn.CONTEXT.]
          Nov 29, 2004 7:44:49 PM org.springframework.web.struts.ContextLoaderPlugIn init
          INFO: Framework servlet 'action' init completed in 3406 ms
          19:44:49  INFO [main] (SpringSupport.java:87) - init() called with context: org.springframework.web.context.support.XmlWebApp
          licationContext: display name [XmlWebApplicationContext for namespace 'action-servlet']; startup date [Mon Nov 29 19:44:46 ES
          T 2004]; root of context hierarchy; config locations=[/WEB-INF/applicationContextAOP.xml];  with sessionFactoryID sessionFact
          ory
          Nov 29, 2004 7:44:51 PM org.apache.struts.tiles.TilesPlugin initDefinitionsFactory
          INFO: Tiles definition factory loaded for module ''.
          Nov 29, 2004 7:44:51 PM org.apache.coyote.http11.Http11Protocol start
          INFO: Starting Coyote HTTP/1.1 on http-80
          Nov 29, 2004 7:44:51 PM org.apache.catalina.startup.Catalina start
          INFO: Server startup in 8157 ms
          Nov 29, 2004 7:44:51 PM org.apache.struts.tiles.TilesRequestProcessor initDefinitionsMapping
          INFO: Tiles definition factory found for request processor ''.
          19:44:51 DEBUG [http-80-Processor4] (GamesValidatorForm.java:77) - validate() on page 0 has errors numbering 0
          The INFO statements have a different layout than my DEBUGS. I'll play more with the configuration between Commons and Log4J and let you know.

          Comment

          Working...
          X