logback-spring.xml
<appender name="cbmu_data_file" class="ch.qos.logback.core.rolling.RollingFileAppender">
<append>true</append>
<param name="bufferedIO" value="true"/>
<param name="bufferSize" value="8192"/>
<encoder>
<charset>UTF-8</charset>
<pattern>${cbmu_log_pattern}</pattern>
</encoder>
<file>${logging.path}/${serviceName}-cbmu.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${logging.path}/%d{yyyy_MM_dd}/${serviceName}-cbmu-%d{HH_mm_ss}.%i.log.zip</fileNamePattern>
<maxHistory>7</maxHistory>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>40MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>INFO</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<springProfile name="prod">
<root level="INFO">
<appender-ref ref="info_file"/>
<appender-ref ref="warn_file"/>
<appender-ref ref="error_file"/>
</root>
</springProfile>
<springProfile name="test">
<root level="INFO">
<appender-ref ref="info_file"/>
<appender-ref ref="warn_file"/>
<appender-ref ref="error_file"/>
</root>
</springProfile>
<logger name="cbmuDataFile" level="info">
<appender-ref ref="cbmu_data_file"/>
</logger>
Java中使用
private static final Logger log = LogManager.getLogger("cbmuDataFile");
log .info("=====");
|