[logback-user] log rollover using %d multiple times in file name pattern?
Thomas Corte
Thomas.Corte at knipp.de
Wed Dec 21 11:13:29 CET 2011
Hi Ceki,
On 20.12.2011 16:36, ceki wrote:
> 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.
Thanks for the quick reply.
I just created http://jira.qos.ch/browse/LBCORE-242 to cover this.
> 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.
I guess both will get the job done, though the 2nd solution seems a
little less kludgy to me.
That said, it could be argued that using the file name pattern for
specifying both, file names and the rollover period, is somewhat
convenient, but violates the principle of "separation of concerns" to
some extent. A dedicated (optional) property to specify the rollover
period separately may be the best solution.
But of course it's your call.
Best regards,
Thomas
--
Thomas Corte
Thomas.Corte at knipp.de
More information about the Logback-user
mailing list