Announcement Announcement Module
Collapse
No announcement yet.
Spring Logging Configuration Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

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

    Comment


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

      Comment


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

        Comment

        Working...
        X