一、简介

支持日志框架:Java Util Logging, Log4J2 and Logback,默认是使用logback

对于日志的快捷方式:@Slf4j注解

    

注意:@Slf4j注解需要导入lombok包,pom如下:

   
org.projectlombok
   
lombok

对于log的connot resolve symbol log的红叉提示,解决:

  1.用快捷键Ctrl+Alt+S打开:Settings→Plugins→Browse repositories

 2.输入lom后选择Install,安装插件

     

logback配置方式

spring boot默认会加载classpath:logback-spring.xml或者classpath:logback-spring.groovy

 

使用自定义配置文件,配置方式为:

logging.config=classpath:logback-roncoo.xml

注意:不要使用logback这个来命名,否则spring boot将不能完全实例化

logback-spring.xml:

    
    
    
    
    
    
    
    
        
            
smtp.163.com
            
发送的@163.com
            
密码
            
a1754966750@qq.com
            
发送的@163.com
            
hystrix-dashboard
            
                
${PATTERN}
                        
                
                
ERROR
                
ACCEPT
                
DENY
                            
            
                
${PATTERN}
            
            
                
                
debug
                            
        
        
        
        
        
        
            
            
        
        
    
        
        
            
            
${TEST_FILE_PATH}
            
                
                
${TEST_FILE_PATH}/info.%d{yyyy-MM-dd}.log
                
                
100
                        
                
${PATTERN}
                            
            
                
    
        
            
${PRO_FILE_PATH}
            
                
${PRO_FILE_PATH}/warn.%d{yyyy-MM-dd}.log
                
100
                        
                
${PATTERN}