There’s also the fact that lookups are usable in layouts that don’t reuse 
pattern layout components. Note that there are also differences in how objects 
are allocated for different plugins when GC-free logging is a concern.

—
Matt Sicker

> On Sep 2, 2022, at 00:47, Piotr P. Karwasz <piotr.karw...@gmail.com> wrote:
> 
> 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 <rickq...@gmail.com> 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: rickq...@gmail.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
> For additional commands, e-mail: log4j-user-h...@logging.apache.org
> 

Reply via email to