self4j日志配置


<configuration scan="true" scanPeriod="60 seconds" debug="false">
    
    <property name="log.path" value="logs/aiLogs"/>
    
    <property name="log.pattern"
              value="%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>

    
    <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <pattern>${log.pattern}pattern>
        encoder>
    appender>

    
    <appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${log.path}/info.logfile>
        
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            
            <fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.logfileNamePattern>
            
            <maxHistory>60maxHistory>
        rollingPolicy>
        <encoder>
            <pattern>${log.pattern}pattern>
        encoder>
        <filter class="ch.qos.logback.classic.filter.LevelFilter">
            
            <level>INFOlevel>
            
            <onMatch>ACCEPTonMatch>
            
            <onMismatch>DENYonMismatch>
        filter>
    appender>

    <appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${log.path}/error.logfile>
        
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            
            <fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.logfileNamePattern>
            
            <maxHistory>60maxHistory>
        rollingPolicy>
        <encoder>
            <pattern>${log.pattern}pattern>
        encoder>
        <filter class="ch.qos.logback.classic.filter.LevelFilter">
            
            <level>ERRORlevel>
            
            <onMatch>ACCEPTonMatch>
            
            <onMismatch>DENYonMismatch>
        filter>
    appender>

    
    <logger name="com.saas" level="debug"/>
    
    <logger name="org.springframework" level="warn"/>

    <root level="info">
        <appender-ref ref="console"/>
    root>

    
    <root level="info">
        <appender-ref ref="file_info"/>
        <appender-ref ref="file_error"/>
    root>
configuration>

你可能感兴趣的:(java)