spring mvc 5与(slf4j+log4j)的组合使用

pom.xml中


      org.slf4j
      slf4j-api
      1.7.25
    
    
      org.slf4j
      slf4j-log4j12
      1.7.25
    

log4j.properties (位于classpath下)

### set log levels ###
log4j.rootLogger = DEBUG, stdout, D, E

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n

log4j.appender.D = org.apache.log4j.RollingFileAppender
log4j.appender.D.File =${catalina.home}/logs/a9.log
log4j.appender.D.Append = true
log4j.appender.D.Threshold = DEBUG
log4j.appender.D.MaxFileSize = 50000KB
log4j.appender.D.layout = org.apache.log4j.PatternLayout
log4j.appender.D.layout.ConversionPattern = %-d{yyyy-MM-dd HH:mm:ss}  [ %t:%r ] - [ %p ]  %m%n

log4j.appender.E = org.apache.log4j.RollingFileAppender
log4j.appender.E.File = ${catalina.home}/logs/a9.log
log4j.appender.E.Append = true
log4j.appender.E.Threshold = ERROR
log4j.appender.E.MaxFileSize = 50000KB
log4j.appender.E.layout = org.apache.log4j.PatternLayout
log4j.appender.E.layout.ConversionPattern =%-d{yyyy-MM-dd HH\:mm\:ss}  [ %l\:%c\:%t\:%r ] - [ %p ]  %m%n

${catalina.home}

是java -Dcatalina.home=xxx,由tomcat执行时传入,该变量可以直接获取到tomcat的安装位置

你可能感兴趣的:(spring mvc 5与(slf4j+log4j)的组合使用)