dev-resources.site
for different kinds of informations.
Kotlin SpringBoot configure Apache Log4j2
Published at
5/5/2021
Categories
kotlin
springboot
log4j2
Author
loizenai
Author
8 person written this
loizenai
open
Kotlin SpringBoot configure Apache Log4j2
Apache Log4j2 is an upgrade to Log4j that provides significant improvements over its predecessor, Log4j 1.x, and provides many of the improvements available in Logback while fixing some inherent problems in Logback’s architecture. The tutorial will introduce way to configure Apache Log4j2 with Kotlin SpringBoot.
I. Technologies
– Java 1.8
– Maven 3.6.1
– Spring Tool Suite – Version 3.9.0.RELEASE
– Spring Boot – 1.5.9.RELEASE
– Kotlin
II. Practice
We use SpringToolSuite to create a Kotlin SpringBoot project as below structure:
Step to do:
- Configure SpringBoot Log4j2 dependencies
- Create a Simple Controller
- Configure Log4j2.xml
- Build & Run
1. Configure SpringBoot Log4j2 dependencies
– Exclude logback from default log dependency of SpringBoot:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
– Add Spring Web MVC dependency:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
– Add Log4j2 dependency
Kotlin SpringBoot configure Apache Log4j2
log4j2 Article's
8 articles in total
Is your Java log utility class reporting itself as the source of your logs? Learn how to fix it!
read article
Maven Resource Filtering: injecting POM' properties in your resources
read article
LogMasker - OpenSource masking library for Java
read article
Log4Shell : JNDI Injection via Attackable Log4J
read article
Log4Shell - Explorando um servidor Java vulnerável
read article
Verify an application has picked up a java property
read article
Kotlin SpringBoot configure Apache Log4j2
currently reading
How to make a custom message converter for Log4J2
read article
Featured ones: