Setting up SLF4J and Log4j2
We will now implement several logging frameworks, including Logback and Log4j2, in our Spring Boot application. Remember that SLF4J is already included.
Configuring Logback
Logback is the default logger used by Spring Applications, so no dependencies need to be installed to use it. The spring-boot-starter-logging
dependency is already included once we create our Spring Boot application. The first step we need to take is to make our Logback configuration file.
In our project, under the resources
folder, we will add the logback-spring.xml
file. This is where we will place our Logback configuration. The following is an example configuration:
<?xml version="1.0" encoding="UTF-8"?> <configuration> <property name="LOGS" value="./logs" /> <!—Please refer to the logback-spring.xml of the GitHub...