Re: Difference between the Date lookup $${date:yyyy-MM} and the Format Specifier %d{yyyy-MM}?

"Piotr P. Karwasz" <[email protected]> Fri, 2 Sep 2022 07:46:55 +0200
Newsgroups gmane.comp.jakarta.log4j.user
Message-ID <CAFmygFag6LokZaRbSG8iq4NdFAOkLXuY7oQBs3tEVoTpp=kh=g@mail.gmail.com>
Hi Rick,
I gave a longer answer about this a couple of months ago on StackOverflow:

https://stackoverflow.com/q/71862896/11748454

Basically the delayed lookup `$${date:...}` uses the current time,
when the rollover occurs, while the pattern `%d{...}` uses the date of
the previous rollover.

A `RollingFileAppender` also uses the first (and hopefully only)
pattern it finds to determine the rollover frequency.

Piotr

On Fri, 2 Sept 2022 at 06:21, Rick <[email protected]> wrote:
>
> Hi,
>
> I am new to Log4j2, and I am a little bit confused with the Date lookup
> $${date:yyyy-MM} and the Format Specifier %d{yyyy-MM}.
> Please see the following configuration:
>
> <RollingRandomAccessFile name="log2file" fileName="logs/app.log"
> filePattern="logs/*$${date:yyyy-MM}*/app-*%d{MM-dd-yyyy}*-%i.log.gz">
>
>
> --
>
> Sincerely,
>
> *Rick Qin*
> Email: [email protected]