1 <?xml version="1.0" encoding="UTF-8"?> 2 <Configuration> 3 <Appenders> 4 <Console name="Console" target="SYSTEM_OUT"> 5 <PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n" /> 6 </Console> 7 <RollingFile name="RollingFile" fileName="logsl/log/run.txt" filePattern="logsl/all/run-%d{yyyy-MM-dd}-%i.txt"> 8 <PatternLayout> 9 <Pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n</Pattern> 10 </PatternLayout> 11 <Policies> 12 <TimeBasedTriggeringPolicy /> 13 <SizeBasedTriggeringPolicy size="10 MB" /> 14 </Policies> 15 <!-- 此行以下为自动清理日志的配置 --> 16 <DefaultRolloverStrategy> 17 <Delete basePath="logsl/"> 18 <!-- glob 项为需要自动清理日志的pattern --> 19 <IfFileName glob="run-*.txt"/> 20 <!-- 1d 表示自动清理掉2天以前的日志文件 --> 21 <IfLastModified age="7d"/> 22 </Delete> 23 </DefaultRolloverStrategy> 24 <!-- 此行以上为自动清理日志的配置 --> 25 </RollingFile> 26 27 <RollingFile name="RollingFile1" fileName="logsd/data/data.txt" 28 filePattern="log/data/%d{yyyy-MM-dd}/%d{HH}/data-%d{mm}-%i.txt"> 29 <PatternLayout> 30 <Pattern>%msg%n</Pattern> 31 </PatternLayout> 32 <Policies> 33 <TimeBasedTriggeringPolicy interval="2" modulate ="true"/> 34 <SizeBasedTriggeringPolicy size="600KB" /> 35 </Policies> 36 <!-- 此行以下为自动清理日志的配置 --> 37 <DefaultRolloverStrategy> 38 <Delete basePath="log/data/"> 39 <!-- glob 项为需要自动清理日志的pattern --> 40 <IfFileName glob="data-*.txt"/> 41 <!-- 1d 表示自动清理掉2天以前的日志文件 --> 42 <IfLastModified age="7d"/> 43 </Delete> 44 </DefaultRolloverStrategy> 45 <!-- 此行以上为自动清理日志的配置 --> 46 </RollingFile> 47 </Appenders> 48 <Loggers> 49 50 <Root level="all"> 51 <AppenderRef ref="Console" /> 52 <appender-ref ref="RollingFileInfo"/> 53 <appender-ref ref="RollingFileWarn"/> 54 <appender-ref ref="RollingFileError"/> 55 </Root> 56 57 <logger name="runLog" level="INFO" additivity="true"> 58 <AppenderRef ref="RollingFile"/> 59 </logger> 60 61 <logger name="dataLog" level="INFO" additivity="true"> 62 <AppenderRef ref="RollingFile1"/> 63 </logger> 64 </Loggers> 65 </Configuration>