Skip to content

Instantly share code, notes, and snippets.

@cugni
Last active August 29, 2015 14:01
Show Gist options
  • Save cugni/d6d15dd822844da6b786 to your computer and use it in GitHub Desktop.
Save cugni/d6d15dd822844da6b786 to your computer and use it in GitHub Desktop.
Log4j2 via SLF: Config file and pom
// Dependencies for logging
libraryDependencies += "org.apache.logging.log4j" % "log4j-api" % "2.0"
libraryDependencies += "org.apache.logging.log4j" % "log4j-core" % "2.0"
libraryDependencies += "org.apache.logging.log4j" % "log4j-1.2-api" % "2.0"
libraryDependencies += "org.slf4j" % "slf4j-log4j12" % "1.7.7"
<?xml version="1.0" encoding="UTF-8"?>
<!-- Logging for testing -->
<Configuration>
<Appenders>
<Console name="STDOUT" target="SYSTEM_OUT">
<PatternLayout pattern="%d %-5p [%t] %C{2} (%F:%L) - %m%n"/>
</Console>
</Appenders>
<Loggers>
<Logger name="org.apache.log4j.xml" level="debug"/>
<Root level="debug">
<AppenderRef ref="STDOUT"/>
</Root>
</Loggers>
</Configuration>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.0-rc1</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.0-rc1</version>
</dependency>
<!-- bridge between log4j version 1 to log4j2-->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-1.2-api</artifactId>
<version>2.0-rc1</version>
</dependency>
<!-- bridge between log4j and slf4j -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.7</version>
</dependency>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment