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

Aniruddha Shevade ashevade at gmail.com
Mon Feb 12 21:56:53 UTC 2024


Hello
 Thanks for the answer. I am still a bit confused.
If the logback FileNamePattern is "app.log.%d{yyyyMMdd_HHmmss}Z.log", would
this by default mean its going to rollover every second? In other words ,
does the fileNamePattern define the rollover schedule?

You mention using "yyyy-ww"  to trigger a weekly Rollover, would this mean
the fileName pattern should be made
"app.log%d{yyyy-ww}Z.log" ?

Is it possible to decouple the Name of the Rolled over log file and the
tiriggering of RollOver ?  What if  Iwant a rollover every week , but the
name of the Rolled Over file to have hhmmss as part of it? I Sorry if I
have caused confusion here

Best Regards
Ani

On Mon, Feb 12, 2024 at 12:36 PM Ceki Gulcu via logback-user <
logback-user at qos.ch> wrote:

> 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
> >
> _______________________________________________
> logback-user mailing list
> logback-user at qos.ch
> https://mailman.qos.ch/cgi-bin/mailman/listinfo/logback-user
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.qos.ch/pipermail/logback-user/attachments/20240212/ddd4e667/attachment.htm>


More information about the logback-user mailing list