The %d pattern only applies to time based rollovers. If you want the time in a 
size based rollover pattern then use the date lookup  

filePattern=/tmp/msg-$${date:yyyy_MM_dd}/nps-message-$${date:yyyy_MM_dd_HH_mm_ss}.log

Ralph

> On Apr 27, 2020, at 10:39 AM, Benjamin Asbach <contact-...@impl.it> wrote:
> 
> I guess I've been glad to early.
> 
> ```
> appender.msglog.type = RollingFile
> appender.msglog.name = localmsglog
> appender.msglog.filePattern = 
> /tmp/msg-%d{yyyy_MM_dd}/nps-message-%d{yyyy_MM_dd_HH_mm_ss}.log
> appender.msglog.layout.type = log4j1xmllayout
> appender.msglog.policies.type = Policies
> appender.msglog.policies.size.type = SizeBasedTriggeringPolicy
> appender.msglog.policies.size.size = 250MB
> ```
> Is rolling the file as expected.
> 
> I now tried to configure a nightly roll.
> 
> by adding  `appender.msglog.policies.cron.type = CronTriggeringPolicy`. I 
> also tried `appender.msglog.policies.time.type = TimeBasedTriggeringPolicy`. 
> Both results into a single log file `msg-2020_04_27_00_00_00-0.log` and size 
> based logging stops working.
> 
> Any ideas? Maybe I misunderstand some basic concept?
> 
> Thanks in advance
> Benjamin
> 
> On 2020-04-27 17:47, Benjamin Asbach wrote:
>> I guess I found a solution:
>> ```
>> appender.msglog.type = RollingFile
>> appender.msglog.name = localmsglog
>> appender.msglog.filePattern =
>> /tmp/msg-%d{yyyy_MM_dd}/nps-message-%d{yyyy_MM_dd_HH_mm_ss}.log
>> appender.msglog.layout.type = log4j1xmllayout
>> appender.msglog.policies.type = Policies
>> appender.msglog.policies.size.type = SizeBasedTriggeringPolicy
>> appender.msglog.policies.size.size = 250MB
>> ```
>> Sorry for noise.
>> Benjamin
>> On 2020-04-27 16:24, Benjamin Asbach wrote:
>>> Hej!
>>> Currently I try to configure log4j2 to:
>>> * create a log in a folder with dates: e.h.
>>> 2020_04_27/messages.20200427_13_39_01.log
>>> * limit the log size to 250MB
>>> (* use a custom layout)
>>> (* rollover every day)
>>> But I'm already stuck with the first two bullets
>>> ```
>>> appender.msglog.type = RollingFile
>>> appender.msglog.name = localmsglog
>>> appender.msglog.filePattern =
>>> /tmp/msg-${date:yyyy_MM_dd}/nps-message-${date:yyyy_MM_dd_HH_mm_ss}.log
>>> appender.msglog.layout.type = log4j1xmllayout
>>> appender.msglog.policies.type = Policies
>>> appender.msglog.policies.size.type = SizeBasedTriggeringPolicy
>>> appender.msglog.policies.size.size = 250MB
>>> appender.msglog.strategy.type = DirectWriteRolloverStrategy
>>> ```
>>> Basically the log is created in the correct folder and with the
>>> correct name. But the file is not rolled after 250MB .
>>> I digged a little bit into the source and recognized that the
>>> `DirectWriteRolloverStrategy` does not get the pattern, but the
>>> current log file name, so it does not contain the `filePattern` at
>>> all.
>>> Now I'm unsure if this is a bug or a configuration issue.
>>> Thanks in advance
>>> Benjamin
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
>>> For additional commands, e-mail: log4j-user-h...@logging.apache.org
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
>> For additional commands, e-mail: log4j-user-h...@logging.apache.org
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
> For additional commands, e-mail: log4j-user-h...@logging.apache.org
> 
> 



---------------------------------------------------------------------
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