springboot使用logback的读取配置文件中的配置项

logback.xml:


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

    
    
        logs/error.log
        
        
            logs/error/error-%d{yyyy-MM-dd}.%i.log.gz
            30
            
                
                100MB
            
        
        
            %d{yyyy-MM-dd HH:mm:ss.SSS} ${PID} [%thread] %-5level %logger{35} - %msg%n
        
        
        
            ERROR
            ACCEPT
            DENY
        
    

    
    
        logs/warn.log
        
        
            logs/warn/warn-%d{yyyy-MM-dd}.%i.log.gz
            
            30
            
                
                100MB
            
        
        
            %d{yyyy-MM-dd HH:mm:ss.SSS} ${PID} [%thread] %-5level %logger{35} - %msg%n
        
        
        
            WARN
            ACCEPT
            DENY
        
    

    
        logs/info.log
        
            logs/info/info-%d{yyyy-MM-dd}.%i.log.gz
            30
            
                
                100MB
            
        
        
            %d{yyyy-MM-dd HH:mm:ss.SSS} ${PID} [%thread] %-5level %logger{35} - %msg%n
        
        
            INFO
            ACCEPT
            DENY
        
    

    
    
        
            
                ${driverClassName}
                ${jdbcUrl}
                ${username}
                ${password}
            
        
        
        
            WARN
            ACCEPT
            DENY
        
    
    
        
            
                ${driverClassName}
                ${jdbcUrl}
                ${username}
                ${password}
            
        
        
            ERROR
            ACCEPT
            DENY
        
    

    
        
    

    
    
        
        
        
        
        
        
    

application.yml:

## portal DB
portal.jdbc:
  type: mysql
  driverClassName: com.mysql.jdbc.Driver
#  jdbcUrl: jdbc:mysql://10.100.1.85:3306/frms-mt-mgr2.2?useUnicode=true&characterEncoding=UTF-8
  jdbcUrl: jdbc:mysql://10.100.1.85:3306/frms-mt-mgr2.3?useUnicode=true&characterEncoding=UTF-8
#  jdbcUrl: jdbc:mysql://127.0.0.1:3306/frms-mt-mgr2.1?useUnicode=true&characterEncoding=UTF-8
  username: 
#  password: 
  password: 
  connectionTestQuery: SELECT 1 FROM DUAL
  maximumPoolSize: 10
  minimumIdle: 1
  maxLifetime: 2000000
  connectionTimeout: 30000
  idleTimeout: 30000

转载于:https://my.oschina.net/yejw/blog/1551697

你可能感兴趣的:(springboot使用logback的读取配置文件中的配置项)