I always forget it, so make a note here.
At a minimum, the following files are required. log4j-core-2.13.3.jar log4j-api-2.13.3.jar (2.13.3 is the latest version at the time of writing this)
★ If you want to connect with commons-logging, you also need log4j-jcl-2.13.3.jar. Click here for details: https://stackoverflow.com/questions/41462181/commons-logging-with-log4j2
pom.xml
pom.xml
<!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.13.3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-api -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.13.3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-jcl -->
<!-- https://stackoverflow.com/questions/41462181/commons-logging-with-log4j2 -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-jcl</artifactId>
<version>2.13.3</version>
</dependency>
log4j2.xml
log4j2.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE project>
<Configuration status="off">
<Properties>
<Property name="format1">%d{yyyy/MM/dd HH:mm:ss.SSS} [%t] %-6p %c{10} %m%n</Property>
</Properties>
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout>
<pattern>${format1}</pattern>
</PatternLayout>
</Console>
</Appenders>
<Loggers>
<Root level="trace">
<AppenderRef ref="Console" />
</Root>
</Loggers>
</Configuration>
Reference link: https://qiita.com/mato-599/items/979e10135c1cb54ceda9 https://qiita.com/pica/items/f801c74848f748f76b58
that's all
Recommended Posts