Logback

Logback配置

XML形式



    
    
        
            %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %5level %logger{50} - %msg%n
        
    
    
    
    
    
    
    
    
    

YML形式

logging:
  pattern:
    console: "%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %5level %logger{50} - %msg%n"
  file: ./logs/xxx.log
  level:
    com.ibatis: DEBUG
    com.ibatis.common.jdbc.SimpleDataSource: DEBUG
    com.ibatis.common.jdbc.ScriptRunner: DEBUG
    com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate: DEBUG
    java.sql.Connection: DEBUG
    java.sql.Statement: DEBUG
    java.sql.PreparedStatement: DEBUG
    org.lins.demo: INFO

Java启动/停止

启动:nohup java -jar xxx.jar > /dev/null &
停止:jobs查看后台服务,然后kill %运行的ID值

Spring Boot配置源码

Spring Boot中logback的配置源码在spring-boot-1.5.4.RELEASE.jar的org.springframework.boot.logging.logback包下,包含10个类和4个配置文件。

配置文件

base.xml







    
    
    
    
    
    
    
        
        
    

defaults.xml






    
    
    
    
    

    
        org.springframework.boot
    

    
    
    
    
    
    
    
    
    
    
    
        
    
    
        
    

console-appender.xml







    
        
            
            ${CONSOLE_LOG_PATTERN}
            utf8
        
    

file-appender.xml







    
        
            
            ${FILE_LOG_PATTERN}
        
        ${LOG_FILE}
        
            ${LOG_FILE}.%i
        
        
            10MB
        
    

配置类

1. ColorConverter

2. DefaultLogbackConfiguration

3. ExtendedWhitespaceThrowableProxyConverter

4. LevelRemappingAppender

5. LogbackConfigurator

6. LogbackLoggingSystem

7. SpringBootJoranConfigurator

8. SpringProfileAction

9.SpringPropertyAction

10. WhitespaceThrowableProxyConverter

你可能感兴趣的:(Logback)