Results 1 to 4 of 4

Thread: Spring Logging Configuration

  1. #1
    Join Date
    Jul 2005
    Posts
    15

    Default Spring Logging Configuration

    Is there documentation anywhere on how logging works in Spring. I'm using the JdbcTemplate and trying to get all of the SQL queries outputted to the stdout however I'm not sure how to get this to work.

    Thanks.

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

    Default

    Is there documentation anywhere on how logging works in Spring.
    You can look at the JavaDocs and samples. You can set it up in your web.xml:
    Code:
    	<context-param>
    		<param-name>log4jConfigLocation</param-name>
    		<param-value>/WEB-INF/log4j.properties</param-value>
    	</context-param>
    I'm using the JdbcTemplate and trying to get all of the SQL queries outputted to the stdout
    You can try something like:
    Code:
    #Spring JdbcTemplate logging
    log4j.logger.org.springframework.jdbc.core.JdbcTemplate=DEBUG, springlogfile
    
    log4j.appender.springlogfile=org.apache.log4j.RollingFileAppender
    log4j.appender.springlogfile.File=$&#123;webapp.root&#125;/WEB-INF/springJdbcTemplate.log
    log4j.appender.springlogfile.MaxFileSize=10MB
    # Keep three backup files
    log4j.appender.springlogfile.MaxBackupIndex=3
    log4j.appender.springlogfile.layout=org.apache.log4j.PatternLayout
    # Pattern to output&#58; date priority &#91;category&#93; - <message>line_separator
    log4j.appender.springlogfile.layout.ConversionPattern=%d %p &#91;%c&#93; - <%m>%n

  3. #3
    Join Date
    Jul 2005
    Posts
    15

    Default

    Thanks a lot for your help.
    It seems like you also need to put in the Log4jConfigListener in web.xml.
    Code:
    <listener>
    <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
    </listener>

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

    Default

    It seems like you also need to put in the Log4jConfigListener in web.xml
    Absolutely - it's what uses the log4jConfigLocation parameter.

Similar Threads

  1. Gaijin Studio for Spring MVC 0.9.2 Released
    By dadams in forum Announcements
    Replies: 8
    Last Post: May 30th, 2007, 10:48 PM
  2. Spring logging configuration
    By ASavitsky in forum Container
    Replies: 1
    Last Post: Aug 15th, 2005, 03:19 PM
  3. A Spring Class Loader?
    By azzoti in forum Architecture
    Replies: 8
    Last Post: May 7th, 2005, 04:02 AM
  4. Replies: 14
    Last Post: Feb 21st, 2005, 05:41 PM
  5. Replies: 5
    Last Post: Aug 27th, 2004, 07:13 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
  •