[logback-user] Writting logs to current date

Srikanth Hugar srikanth.hugar at gmail.com
Mon Apr 6 07:08:21 CEST 2015


Hello I am using logback to write files and i have the below mentioned
appender configuration.
Below configuration works fine.

My question is,how to write the logs in current directory? Is it possible?

Currently written as, What i am looking is to write karaf.log on current
date directory. Would be helpful, if some experts could let me know about
the changes.

*2015-04-03*
*2015-04-04*
*2015-04-05*

*karaf.log*

<appender name="FILE"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>data/log/karaf.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- daily rollover -->
<fileNamePattern>data/log/%d{yyyy-MM-dd}/karaf.%d{yyyy-MM-dd}.%i.gz
</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<!-- or whenever the file size reaches 10MB -->
<maxFileSize>10MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<!-- keep 10 days worth of history -->
<maxHistory>10</maxHistory>
</rollingPolicy>
<append>true</append>
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
</pattern>
</encoder>
</appender>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.qos.ch/pipermail/logback-user/attachments/20150406/29dfeea9/attachment.html>


More information about the Logback-user mailing list