Created
February 5, 2016 14:32
-
-
Save ogregoire/692024d32824a86d591d to your computer and use it in GitHub Desktop.
Log4J 2 - Rolling file with deletion after 60 days.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="UTF-8"?> | |
| <Configuration status="warn" name="MyApp" packages=""> | |
| <Properties> | |
| <Property name="baseDir">logs</Property> | |
| </Properties> | |
| <Appenders> | |
| <RollingFile name="RollingFile" fileName="${baseDir}/app.log" | |
| filePattern="${baseDir}/$${date:yyyy-MM}/app-%d{yyyy-MM-dd}.log.gz"> | |
| <PatternLayout pattern="%d %p %c{1.} [%t] %m%n" /> | |
| <CronTriggeringPolicy schedule="0 0 0 * * ?"/> | |
| <DefaultRolloverStrategy> | |
| <Delete basePath="${baseDir}" maxDepth="2"> | |
| <IfFileName glob="*/app-*.log.gz" /> | |
| <IfLastModified age="60d" /> | |
| </Delete> | |
| </DefaultRolloverStrategy> | |
| </RollingFile> | |
| </Appenders> | |
| <Loggers> | |
| <Root level="error"> | |
| <AppenderRef ref="RollingFile"/> | |
| </Root> | |
| </Loggers> | |
| </Configuration> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment