Results 1 to 5 of 5

Thread: Spring Framework DEBUG logging with Log4J

  1. #1
    Join Date
    Nov 2004
    Location
    Atlanta, GA, USA
    Posts
    42

    Default 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. #2
    Join Date
    Aug 2004
    Location
    Sydney, Australia
    Posts
    2,768

    Default

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

  3. #3
    Join Date
    Nov 2004
    Location
    Atlanta, GA, USA
    Posts
    42

    Default

    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.

  4. #4
    Join Date
    Aug 2004
    Location
    Sydney, Australia
    Posts
    2,768

    Default

    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.

  5. #5
    Join Date
    Nov 2004
    Location
    Atlanta, GA, USA
    Posts
    42

    Default

    Quote 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.

Similar Threads

  1. Spring container fails with no exception
    By naor in forum Container
    Replies: 9
    Last Post: Oct 1st, 2005, 03:39 PM
  2. EHCaching Hibernate
    By dencamel in forum Data
    Replies: 3
    Last Post: Sep 6th, 2005, 09:03 PM
  3. Replies: 4
    Last Post: Aug 17th, 2005, 04:42 AM
  4. Loosing my SecureContext
    By sklakken in forum Security
    Replies: 3
    Last Post: Jul 21st, 2005, 01:44 PM
  5. Stack Overflow
    By rayho222 in forum Container
    Replies: 6
    Last Post: May 17th, 2005, 03:42 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
  •