Friday, April 10, 2015

how to log4j configuration for spring

web.xml file

<!-- log4j config for spring -->
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>file:/C:/Users/jupiter/workspace/webapp4_custformdbbcryptcond2/src/main/resources/welcome/log4j.properties</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>


log4j.properties file

# Root logger option
log4j.rootLogger=debug, file, stdout
#log4j.rootLogger=debug, stdout


# Direct log messages to a log file
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=C:/logs/log.log
log4j.appender.file.MaxFileSize=1MB
log4j.appender.file.MaxBackupIndex=1
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{dd MMM yyyy HH:mm:ss} ----%5p----

 

No comments:

Post a Comment