This commit features a number of tests for programmatically configuring log4j. Note that in order to have these tests live together, there is a slight deviation in how these are configured vs how they are in the real world, specifically around static initialization. Generally speaking, whenever static initialization is needed for a given configuration, it is embedded in a @BeforeClass-annotated JUnit method. Also, to isolate the tests from each other's plugins, annotation processing was turned off in the build. This is not required when doing programmatic configuration of log4j. It is simply needed for the specific use case of demonstrating these various log4j plugins all in the same module.
78 lines
2.6 KiB
XML
78 lines
2.6 KiB
XML
<?xml version="1.0" encoding="UTF-8"?>
|
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
<modelVersion>4.0.0</modelVersion>
|
|
<artifactId>log4j2</artifactId>
|
|
|
|
<parent>
|
|
<groupId>com.baeldung</groupId>
|
|
<artifactId>parent-modules</artifactId>
|
|
<version>1.0.0-SNAPSHOT</version>
|
|
<relativePath>../../</relativePath>
|
|
</parent>
|
|
|
|
<dependencies>
|
|
<!-- This is the needed core component. -->
|
|
<dependency>
|
|
<groupId>org.apache.logging.log4j</groupId>
|
|
<artifactId>log4j-core</artifactId>
|
|
<version>${log4j-core.version}</version>
|
|
</dependency>
|
|
|
|
<!-- This is used by JSONLayout. -->
|
|
<dependency>
|
|
<groupId>com.fasterxml.jackson.core</groupId>
|
|
<artifactId>jackson-databind</artifactId>
|
|
<version>${jackson.version}</version>
|
|
</dependency>
|
|
|
|
<!-- This is used by XMLLayout. -->
|
|
<dependency>
|
|
<groupId>com.fasterxml.jackson.dataformat</groupId>
|
|
<artifactId>jackson-dataformat-xml</artifactId>
|
|
<version>${jackson.version}</version>
|
|
</dependency>
|
|
|
|
<!-- This is used by JDBC Appender. -->
|
|
<dependency>
|
|
<groupId>com.h2database</groupId>
|
|
<artifactId>h2</artifactId>
|
|
<version>${h2.version}</version>
|
|
</dependency>
|
|
<dependency>
|
|
<groupId>org.apache.commons</groupId>
|
|
<artifactId>commons-dbcp2</artifactId>
|
|
<version>${commons-dbcp2.version}</version>
|
|
</dependency>
|
|
|
|
<!-- This is used for testing only. -->
|
|
<dependency>
|
|
<groupId>org.apache.logging.log4j</groupId>
|
|
<artifactId>log4j-core</artifactId>
|
|
<version>${log4j-core.version}</version>
|
|
<type>test-jar</type>
|
|
<scope>test</scope>
|
|
</dependency>
|
|
</dependencies>
|
|
|
|
<properties>
|
|
<jackson.version>2.9.5</jackson.version>
|
|
<h2.version>1.4.193</h2.version>
|
|
<commons-dbcp2.version>2.1.1</commons-dbcp2.version>
|
|
<log4j-core.version>2.11.0</log4j-core.version>
|
|
</properties>
|
|
|
|
<build>
|
|
<plugins>
|
|
<plugin>
|
|
<groupId>org.apache.maven.plugins</groupId>
|
|
<artifactId>maven-compiler-plugin</artifactId>
|
|
<version>3.7.0</version>
|
|
<configuration>
|
|
<proc>none</proc>
|
|
</configuration>
|
|
</plugin>
|
|
</plugins>
|
|
</build>
|
|
</project>
|