[logback-user] migration from log4j to logback. help with specific log4j.xml property (CronTriggerPolicy>

Ceki Gulcu ceki at qos.ch
Mon Feb 12 20:36:00 UTC 2024


Hi Ani,

Logback does not support cron-like triggering. However, it supports
triggering based on a date pattern, e.g "yyyy-MM-dd"

The schedule "0 0 * * 1 ?" corresponds to first day of the week at
midnight. The pattern "yyyy-ww" corresponds to the same triggering
schedule.

The link below provides more details:

https://logback.qos.ch/manual/appenders.html#tbrpFileNamePattern

I hope this helps,

-- 
Ceki Gülcü

Sponsoring SLF4J/logback/reload4j at https://github.com/sponsors/qos-ch

On 2/12/2024 8:44 PM, Aniruddha Shevade via logback-user wrote:
> Hello
>  I am trying to migrate a application form log4j to logback. I do have
> the following property defined in the existing log4j2.xml file, I do not
> see any such equivalent in the logback.xml.
> *How do I specify something like a CronTriggerPolicy as shown below?*
> Any help would be appreciated.
> 
> log4j2.xml
> 
> <RollingFile name="myLog" fileName="app.log" 
> filePattern"app.log.%d{yyyyMMdd_HHmmzz}Z.log>
> <Policies>
> *     <CronTiggerPolicy schedule="0 0 * * 1 ?" evaluateOnStartup="true">*
>     <SizeBasedTriggerPolicy size="10MB"/>
> </Policies>
> </RollingFile>
> 
> 
> Best regards
> Ani
> 


More information about the logback-user mailing list