Details
-
Bug
-
Status: Open
-
Minor
-
Resolution: Unresolved
-
2.10.0
-
None
-
None
-
windows 10
Description
My logs are store in daily folders, such as 2018-10-01, 2018-10-02 ... , and i only want last 5 days logs. Log4j2 can delete log files 5 days ago, but the folder were still there, can you delete the folders too?
my config file:
<?xml version="1.0" encoding="UTF-8"?>
<configuration status="WARN">
<Properties>
<Property name="LOG_HOME">logs</Property>
</Properties>
<appenders>
<RollingRandomAccessFile name="RollingInfo"
fileName="${LOG_HOME}/console.log"
filePattern="${LOG_HOME}/$${date:yyyy-MM-dd-HH-mm}/console.log.%d{yyyy-MM-dd_HH-mm-ss}.zip">
<PatternLayout pattern="%d{HH:mm:ss.SSS} %-5level [%thread] %c{1}.%M:%L - %m%n" />
<Policies>
<TimeBasedTriggeringPolicy interval="1" />
</Policies>
<DefaultRolloverStrategy >
<Delete basePath="${LOG_HOME}" maxDepth="2">
<!-<IfFileName glob="/console.log..zip" />->
<IfLastModified age="2M" />
<!-<IfAccumulatedFileCount exceeds="5"/>->
</Delete>
</DefaultRolloverStrategy>
</RollingRandomAccessFile>
</appenders>
<loggers>
<root level="INFO">
<appender-ref ref="RollingInfo" />
</root>
</loggers>
</configuration>