Log4j配置spring+druid打印日志

https://blog.csdn.net/A__yes/article/details/53925404

druid

spring.xml

 
        
        
        
        

        
        

        
        
        
    
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13

log4j.properties加

# Druid
log4j.logger.druid.sql=DEBUG
log4j.logger.druid.sql.DataSource=warn
log4j.logger.druid.sql.Connection=warn
log4j.logger.druid.sql.Statement=DEBUG
log4j.logger.druid.sql.ResultSet=warn
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

Spring

依赖


    
      log4j
      log4j
      ${log4j.version}
    

    
    
      org.slf4j
      slf4j-log4j12
      1.7.2
    
    
    
      org.slf4j
      slf4j-nop
      1.7.9
    

    
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21

log4j.properties加

log4j.logger.org.springframework= warn
  • 1

我的完整配置

log4j.rootLogger = DEBUG, stdout

log4j.logger.org.apache.ibatis=warn
log4j.logger.java.sql=warn
log4j.logger.org.springframework= warn

# Druid
log4j.logger.druid.sql=DEBUG
log4j.logger.druid.sql.DataSource=warn
log4j.logger.druid.sql.Connection=warn
log4j.logger.druid.sql.Statement=DEBUG
log4j.logger.druid.sql.ResultSet=warn


log4j.appender.stdout           = org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target    = System.out
log4j.appender.stdout.Threshold = DEBUG
log4j.appender.stdout.layout    = org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern =  %-d{yyyy-MM-dd HH:mm:ss}  [ %p ]  %m%n

你可能感兴趣的:(Java_Ibatis)