slf4j + logback 输出日志:mybatis sql语句

1 引入jar包:maven resposity 中 选择logback classic module

slf4j + logback 输出日志:mybatis sql语句_第1张图片

 


ch.qos.logback
logback-classic
1.2.3


2 添加logback.xml 配置文件


    
        
            %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
        
    

    
        d:/logs/carmall-manager.log
        
            d:/logs/carmall-manager.%d{yyyy-MM-dd}.log
        
        
            %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
        
    

    
    

    
    
    
    
    
    
    
    
    
    
    
        
        
        
        
    

  最后输出日志

22:25:42,179 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [java.sql.PreparedStatement] to DEBUG
22:25:42,179 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [java.sql.ResultSet] to DEBUG
22:25:42,179 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to INFO
22:25:42,179 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [console] to Logger[ROOT]
22:25:42,180 |-ERROR in ch.qos.logback.core.joran.action.AppenderRefAction - Could not find an appender named [cn.iautos.manager]. Did you define it below instead of above in the configuration file?
22:25:42,180 |-ERROR in ch.qos.logback.core.joran.action.AppenderRefAction - See http://logback.qos.ch/codes.html#appender_order for more details.
22:25:42,180 |-ERROR in ch.qos.logback.core.joran.action.AppenderRefAction - Could not find an appender named [com.ibatis]. Did you define it below instead of above in the configuration file?
22:25:42,180 |-ERROR in ch.qos.logback.core.joran.action.AppenderRefAction - See http://logback.qos.ch/codes.html#appender_order for more details.
22:25:42,180 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [rollingFile] to Logger[ROOT]
22:25:42,180 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.
22:25:42,181 |-INFO in ch.qos.logback.classic.joran.JoranConfigurator@7d417077 - Registering current configuration as safe fallback point

22:25:42.649 [main] DEBUG mapper.UserMapperI.getUser - ==>  Preparing: select * from users where id=? 
22:25:42.704 [main] DEBUG mapper.UserMapperI.getUser - ==> Parameters: 1(Integer)
22:25:42.742 [main] DEBUG mapper.UserMapperI.getUser - <==      Total: 1
User{id='1', name='test', action='test'}

  

最近在项目中添加日志

如果是spring boot项目的话:
只要在application.properties里面加上

logging.level.com.你的包名=true。就ok


转载于:https://www.cnblogs.com/onfly/p/7748422.html

你可能感兴趣的:(slf4j + logback 输出日志:mybatis sql语句)