A simple logback.xml with daily log rollover feature, keeping 8 days of log history date wise.
More on logback in upcoming posts...
<configuration>
<property name="logdir" value="C:\\MyAppLogs" />
<appender name="LOGFILE"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${logdir}/AppLogs/appInfo.log</file>
<encoder>
<pattern>[ %date ] [%level] [%logger{10}] : %msg%n
</pattern>
</encoder>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<FileNamePattern>${logdir}/AppLogs/appinfo.log.%d{yyyy-MM-dd}.log</FileNamePattern>
<maxHistory>8</maxHistory>
</rollingPolicy>
</appender>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%date %level %logger{10} %msg%n</pattern>
</encoder>
</appender>
<root level="INFO">
<appender-ref ref="LOGFILE" />
<appender-ref ref="STDOUT" />
</root>
</configuration>
No comments:
Post a Comment