[ https://issues.apache.org/jira/browse/LOG4J2-435?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15036192#comment-15036192 ]
Robert Schaft commented on LOG4J2-435: -------------------------------------- {code:xml} <Appenders> <RollingFile name="RollingFile" fileName="logs/app.log" filePattern="logs/$${date:yyyy-MM}/app-%d{MM-dd-yyyy}-%i.log.gz"> <PatternLayout> <Pattern>%d %p %c{1.} [%t] %m%n</Pattern> </PatternLayout> <Policies> <TimeBasedTriggeringPolicy /> <SizeBasedTriggeringPolicy size="250 MB"/> </Policies> </RollingFile> </Appenders> {code} If we had the discussion about those trigger, we would probably end up naming that just slightly different (no function added or removed) and it would be clearer how they are combined: {code:xml} <Appenders> <FileAppender name="RollingFile" fileName="logs/app.log"> <PatternLayout> <Pattern>%d %p %c{1.} [%t] %m%n</Pattern> </PatternLayout> <Rollover filePattern="logs/$${date:yyyy-MM}/app-%d{MM-dd-yyyy}-%i.log.gz"> <Or> <TimeBasedFileNameChange /> <FileSize exceeds="250 MB"/> </Or> </Rollover> </RollingFile> </Appenders> {code} An examples for filter is harder, because they are not well documented and the logic is strange. Let's look at the following example: {code:xml} <Filters> <Marker marker="EVENT" onMatch="ACCEPT" onMismatch="NEUTRAL"/> <DynamicThresholdFilter key="loginId" defaultThreshold="ERROR" onMatch="ACCEPT" onMismatch="NEUTRAL"> <KeyValuePair key="User1" value="DEBUG"/> </DynamicThresholdFilter> </Filters> {code} This could be also {code:xml} <Filter> <Or> <!-- onMatch = ACCEPT, onMismatch=NEUTRAL --> <Marker marker="EVENT"/> <DynamicThresholdFilter key="loginId" defaultThreshold="ERROR"> <KeyValuePair key="User1" value="DEBUG"/> </DynamicThresholdFilter> </Or> </Filters> {code} while {code:xml} <Filters> <Marker marker="EVENT" onMatch="ACCEPT" onMismatch="DENY"/> <DynamicThresholdFilter key="loginId" defaultThreshold="ERROR" onMatch="ACCEPT" onMismatch="DENY"> <KeyValuePair key="User1" value="DEBUG"/> </DynamicThresholdFilter> </Filters> {code} would be {code:xml} <Filter> <And> <!-- onMatch = ACCEPT, onMismatch=DENY --> <Marker marker="EVENT"/> <DynamicThresholdFilter key="loginId" defaultThreshold="ERROR"> <KeyValuePair key="User1" value="DEBUG"/> </DynamicThresholdFilter> </And> </Filters> {code} and what about onMatch=DENY? {code:xml} <Filters> <Marker marker="EVENT" onMatch="DENY" onMismatch="NEUTRAL"/> <DynamicThresholdFilter key="loginId" defaultThreshold="ERROR" onMatch="DENY" onMismatch="NEUTRAL"> <KeyValuePair key="User1" value="DEBUG"/> </DynamicThresholdFilter> </Filters> {code} would be {code:xml} <Filter> <And> <!-- onMatch = DENY, onMismatch=NEUTRAL --> <Not><Marker marker="EVENT"/></Not> <Not> <DynamicThresholdFilter key="loginId" defaultThreshold="ERROR"> <KeyValuePair key="User1" value="DEBUG"/> </DynamicThresholdFilter> </Not> </And> </Filters> {code} It is highly probably that I made some mistakes in these quickly made up filter examples, because the combined filter is so confusing and undocumented. But I think it is nevertheless enough to show, that we have more boolean logic in log4j than you probably assumed. > Feature request: auto-delete older log files > --------------------------------------------- > > Key: LOG4J2-435 > URL: https://issues.apache.org/jira/browse/LOG4J2-435 > Project: Log4j 2 > Issue Type: Improvement > Reporter: Arkin Yetis > Assignee: Remko Popma > Labels: Rollover > Fix For: 2.5 > > Attachments: LimitingRolloverStrategy.java, SizeParser.java > > > Original description: > {quote} > DefaultRolloverStrategy max attribute only applies if you have a %i in the > file pattern. This request is to enhance DefaultRolloverStrategy or another > appropriate component to allow a max number of files limit to apply across > days/months/years when a filePattern includes a date pattern. > {quote} > ---- > One of the most requested features is to add the ability to Log4j to "clean > up" older log files. This usually means deleting these files, although it > could also mean moving them to a different location, or some combination of > these. > Users have different requirements for selecting the files to clean up. A > common request is the ability to keep the last X number of log files. This > works well if rollover is only date based but may give undesired results with > size based rollover. > Another factor to consider is that the directory containing the log files may > contain the log files for multiple appenders, or even files unrelated to > logging. -- This message was sent by Atlassian JIRA (v6.3.4#6332) --------------------------------------------------------------------- To unsubscribe, e-mail: log4j-dev-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-dev-h...@logging.apache.org