Hi Thomas,
See inline response.
On 20.12.2011 15:09, Thomas Corte wrote:
Hello,
I'm trying to configure a log rollover with logs being *rolled daily*
and put into a directory named "yyyy-MM", i.e. one folder for each
*month* containing that month's logs. I'm using the following appender
config:
<appender name="FILE"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>app.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- rollover every minute -->
<fileNamePattern%d{yyyy-MM}/app.%d{yyyy-MM-dd}.log</fileNamePattern>
</rollingPolicy>
<encoder>
<pattern>%d{"yyyy-MM-dd HH:mm:ss,SSS"} [%thread] %-5level %logger{36} -
%msg%n%xEx</pattern>
</encoder>
</appender>
However, it seems as if the current logback implementation merely
considers the first %d specification, which leads to a log rotation only
once per month instead of the desired once per day frequency.
Yes, currently only the first %d token determines the rolling period.
I figure this is because via %d, the log rotation frequency and the file
name pattern are somewhat tied together and seemingly can't be specified
independently.
Is there any way to achieve what I'm trying to do without writing custom
code?
I've started working on this problem. Can you please enter a bug report
requesting this future along the lines of your email post? It makes
referencing easier.
Here are some possible solutions.
First solution: add an option, say SECONDARY, to %d so that the token is
*not* taken into account when determining the rollover period.
you would write:
<FileNamePattern>%d{yyyy-MM,SECONDARY}/app.%d{yyyy-MM-dd}.log</File...>
Second solution: use a different identifier for the token, for example
%t instead of %d.
you would write:
<FileNamePattern>%t{yyyy-MM}/app.%d{yyyy-MM-dd}.log</FileNamePattern>
I have a slight preference for the first solution because it involves
less code changes.
Best regards,
Thomas
--
Ceki
http://twitter.com/#!/ceki
_______________________________________________
Logback-user mailing list
[email protected]
http://mailman.qos.ch/mailman/listinfo/logback-user