Skip to content

Instantly share code, notes, and snippets.

@milovtim
Last active December 7, 2018 10:15
Show Gist options
  • Save milovtim/c19ebd15f82b9d2b4defd7985d72874e to your computer and use it in GitHub Desktop.
Save milovtim/c19ebd15f82b9d2b4defd7985d72874e to your computer and use it in GitHub Desktop.
LOG_PATH -- env/local var of log files location, FILE_LOG_PATTERN -- env/local val with pattern
def tmpl = {
"""
<appender name="${it.toUpperCase()}_FILE"
additivity="false"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>\${LOG_PATH}/${it.toLowerCase()}.log</file>
<encoder><pattern>\${FILE_LOG_PATTERN}</pattern></encoder>
<append>true</append>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>\${LOG_PATH}/old/${it.toLowerCase()}_%d{yyyy-MM-dd, aux}/${it.toLowerCase()}.%d{yyyy-MM-dd-HH}.gz</fileNamePattern>
</rollingPolicy>
</appender>
"""
}
['common', 'spring', 'app'].each {
println tmpl(it)
}
@milovtim
Copy link
Author

milovtim commented Dec 7, 2018

Simple rolling file appenders with one hour rolling policy. Archived logs are put to daily named folders.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment