%d{yyyy/MM/dd/}/這類的Pattern就可以達成囉。
請見以下例子
<?xml version="1.0" encoding="UTF-8"?> <configuration debug="true"> <appender name="SYSTEM" class="ch.qos.logback.core.rolling.RollingFileAppender"> <Prudent>true</Prudent> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <FileNamePattern>%d{yyyy/MM/dd/}/System.log</FileNamePattern> </rollingPolicy> <layout class="ch.qos.logback.classic.PatternLayout"> <Pattern>%d [%thread] %-5level %logger{35} - %msg%n </Pattern> </layout> </appender> <appender name="MAIL" class="ch.qos.logback.core.rolling.RollingFileAppender"> <Prudent>true</Prudent> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <FileNamePattern>%d{yyyy/MM/dd/}/Mail.log</FileNamePattern> </rollingPolicy> <layout class="ch.qos.logback.classic.PatternLayout"> <Pattern>%d [%thread] %-5level %logger{35} - %msg%n </Pattern> </layout> </appender> <root level="INFO"> <appender-ref ref="SYSTEM" /> <appender-ref ref="MAIL" /> </root> </configuration>
沒有留言:
張貼留言