You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "ASF subversion and git services (Jira)" <ji...@apache.org> on 2022/09/07 15:51:00 UTC

[jira] [Commented] (LOG4J2-2507) Delete on Rollover must work for DirectWriteRolloverStrategy

    [ https://issues.apache.org/jira/browse/LOG4J2-2507?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17601371#comment-17601371 ] 

ASF subversion and git services commented on LOG4J2-2507:
---------------------------------------------------------

Commit d145ec8ba3f62d469aaeb6f48f5385d7fb8dde06 in logging-log4j2's branch refs/heads/release-2.x from Ralph Goers
[ https://gitbox.apache.org/repos/asf?p=logging-log4j2.git;h=d145ec8ba3 ]

LOG4J2-2507 - Add unit test


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