Last active
March 19, 2018 18:32
-
-
Save jsumners/5921773 to your computer and use it in GitHub Desktop.
A basic Logback configuration template for use in an IntelliJ IDEA file template. Very easily used as a generic template as well.
This file contains 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
<configuration scan="true" scanPeriod="1 minute"> | |
<variable | |
name="logPattern" | |
value="%-30(%d{MMM dd YYYY HH:mm:ss.SSS} [%thread]) %-5level %logger{5} [%file:%line] - %msg%n" /> | |
<!-- | |
The base name of the log file. For "example.log" this would | |
simply be "example". Or if it were "logs/example.log" then | |
"logs/example". | |
The default is set to write to Tomcat's logging directory in a file | |
named after the IntelliJ IDEA project. | |
--> | |
<variable | |
name="logname" | |
value="\${catalina.base}/logs/${PROJECT_NAME}" /> | |
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | |
<!-- encoders are assigned the type | |
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default --> | |
<encoder> | |
<pattern>\${logPattern}</pattern> | |
</encoder> | |
</appender> | |
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> | |
<!-- | |
See http://logback.qos.ch/manual/appenders.html for details. | |
--> | |
<file>\${logname}.log</file> | |
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> | |
<fileNamePattern>\${logname}-%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern> | |
<maxHistory>30</maxHistory> | |
<timeBasedFileNamingAndTriggeringPolicy | |
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> | |
<maxFileSize>100MB</maxFileSize> | |
</timeBasedFileNamingAndTriggeringPolicy> | |
</rollingPolicy> | |
<encoder> | |
<pattern>\${logPattern}</pattern> | |
</encoder> | |
</appender> | |
<root level="debug"> | |
<!-- <appender-ref ref="STDOUT" /> --> | |
<appender-ref ref="FILE" /> | |
</root> | |
</configuration> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
${logname}.log
Where is configured logname ?