[
https://issues.apache.org/jira/browse/LOG4J2-2507?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17601372#comment-17601372
]
Ralph Goers edited comment on LOG4J2-2507 at 9/7/22 3:59 PM:
-------------------------------------------------------------
I've added a unit test that shows the Delete action is working on
DirectWriteRolloverStrategy so something else must be going on here.
Can you add status="TRACE" to your configuration or specify -Dlog4j2.debug=true
and provide the logs from Rollover?
Looking at your filePattern it occurs to me that every time you restart your
app on the same day the file is going to be overwritten. You would need to add
an index to the file name to prevent that.
was (Author: [email protected]):
I've added a unit test that shows the Delete action is working on
DirectWriteRolloverStrategy so something else must be going on here.
Can you add status="TRACE" to your configuration or specify -Dlog4j2.debug=true
and provide the logs from Rollover?
> Delete on Rollover must work for DirectWriteRolloverStrategy
> -------------------------------------------------------------
>
> Key: LOG4J2-2507
> URL: https://issues.apache.org/jira/browse/LOG4J2-2507
> Project: Log4j 2
> Issue Type: Improvement
> Affects Versions: 2.11.1
> Reporter: lionel sauron
> Priority: Major
> Attachments: ScreenShot-132.png, ScreenShot-133.png
>
>
> Delete on Rollover is limited to DefaultRolloverStrategy
> Why not to add the same feature to the DirectWriteRolloverStrategy ?
>
> +Edit :+
> What i want :
> * For Each startup use a log file with the date in its name
> * For multiple startup the same day, append log in the same file
> * Keep only the last 10 log files
>
> If i use DefaultRolloverStrategy, i can keep the last 10 startup in separate
> file and use DeleteAction to limit the number of log file (for test i use 10,
> but in prod it's 100 = 10 days * 10 startup)
> => It's bad for me, because i can't have more than 10 startup per day logged.
> See the result in ScreenShot-132.png
> {noformat}
> <RollingFile name="ROCOPYTRACE" filename = "${basePath}/robocopy.log"
> filePattern = "${basePath}/robocopy-%d{yyyyMMdd}-%i.log">
> <PatternLayout pattern="%msg%n"/>
> <Policies>
> <OnStartupTriggeringPolicy />
> </Policies>
> <DefaultRolloverStrategy max="10">
> <Delete basePath = "${basePath}">
> <IfFileName glob="robocopy-*.log">
> <IfAccumulatedFileCount exceeds="10"/>
> </IfFileName>
> </Delete>
> </DefaultRolloverStrategy>
> </RollingFile>{noformat}
>
> If i use DirectWriteRolloverStrategy i can have 1 file per day.
> But DeleteAction is never run and i have too many file
> See the result in ScreenShot-133.png
>
> {noformat}
> <RollingFile name="ROCOPYTRACE" filePattern =
> "${basePath}/robocopy-%d{yyyyMMdd}.log">
> <PatternLayout pattern="%msg%n"/>
> <Policies>
> <OnStartupTriggeringPolicy />
> </Policies>
> <DirectWriteRolloverStrategy>
> <Delete basePath = "${basePath}">
> <IfFileName glob="robocopy-*.log">
> <IfAccumulatedFileCount exceeds="10"/>
> </IfFileName>
> </Delete>
> </DirectWriteRolloverStrategy>
> </RollingFile>{noformat}
>
> Il i useTimeBasedTriggeringPolicy or CronTriggeringPolicy and
> DefaultRolloverStrategy then a run can be split into 2 file.
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)