0

Helllo everyone,

we have log4j from 1.2.8 to log4j2.11, and observed half daily logs files are not generating as expected.Only i can see only AM log files are generating.

<RollingFile name="file" fileName="testAMPM.log" filePattern="testAMPM.log-%d{yyyy-MM-dd-a}" >
      
        <PatternLayout pattern="%d %5p %-120m [%t - %c:%L] %n"/>
        <Policies>
            <TimeBasedTriggeringPolicy interval="1" modulate="true" />
        </Policies>

1 Answers1

0

Will not mark this as duplicate because this, question here did not get answered. The answer to another duplicate question does have an example though, so please try this here first:

<RollingFile name="fileAppender" filename ="${logName} append="true" FilePattern="${logName}.$$d{yyyy-MM-dd-a}">
    <CronTriggeringPolicy schedule="0 0 0,12 * * ?" />
</RollingFile>

A comment in the first linked duplicate also suggests to check out Cron Triggering Policy, which could provide a better solution to your requirement than a TimeBasedTriggeringPolicy: enter image description here

Just try it out.

metters
  • 533
  • 1
  • 8
  • 17