Log4j2

To use Log4j2, we need to use the starter spring-boot-starter-log4j2. When we use starters such as spring-boot-starter-web, we need to ensure that we exclude the dependency in spring-boot-starter-logging. The following snippet shows the details:

    <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>    <dependency>      <groupId>org.springframework.boot</groupId>      <artifactId>spring-boot-starter-log4j2</artifactId>    </dependency>

The following snippet shows the dependencies used in the spring-boot-starter-log4j2 starter:

 <dependency> ...

Get Mastering Spring 5.0 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.