Created
April 24, 2020 15:26
-
-
Save kathyrollo/4346deb94046771cd51199be2b74dc6c to your computer and use it in GitHub Desktop.
SLF4J with Log4j2
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"> | |
<Properties> | |
<Property name="logPath">target/test-logs</Property> | |
<Property name="rollingFileName">test-log</Property> | |
</Properties> | |
<Appenders> | |
<Console name="console" target="SYSTEM_OUT"> | |
<PatternLayout pattern="[%highlight{%-5level}] %d{DEFAULT} %c{1}.%M() - %msg%n%throwable{short.lineNumber}" /> | |
</Console> | |
<RollingFile name="rollingFile" fileName="${logPath}/${rollingFileName}.log" filePattern="${logPath}/${rollingFileName}_%d{yyyy-MM-dd}.log"> | |
<PatternLayout pattern="[%highlight{%-5level}] %d{DEFAULT} %c{1}.%M() - %msg%n%throwable{short.lineNumber}" /> | |
<Policies> | |
<!-- Causes a rollover if the log file is older than the current JVM's start time --> | |
<OnStartupTriggeringPolicy /> | |
<!-- Causes a rollover once the date/time pattern no longer applies to the active file --> | |
<TimeBasedTriggeringPolicy interval="1" modulate="true" /> | |
</Policies> | |
</RollingFile> | |
</Appenders> | |
<Loggers> | |
<Root level="DEBUG" additivity="false"> | |
<AppenderRef ref="console" /> | |
<AppenderRef ref="rollingFile" /> | |
</Root> | |
</Loggers> | |
</Configuration> |
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
<dependency> | |
<groupId>org.apache.logging.log4j</groupId> | |
<artifactId>log4j-slf4j-impl</artifactId> | |
<version>${slf4j}</version> | |
</dependency> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment