Spring Boot Logger Configuration Example

  • Overview of Spring Boot Logger Configuration Example:

In this article, We are going explain the Spring Boot Logger Configuration Example.

We can configure the Logger in two ways.

  1. application.properties
  2. application.yml

Configuration file contain below properties.

  • logging.level.* : It is used as prefix with package name to set log level.
  • logging.file : It configures a log file name to log message in file. We can also configure file name with absolute path.
  • logging.path : It only configures path for log file. Spring boot creates a log file with name spring.log.
  • logging.pattern.console : It defines logging pattern in console.
  • logging.pattern.file: It defines logging pattern in file.
  • logging.pattern.level: It defines the format to render log level. Default is %5p.
  • logging.exception-conversion-word : It defines conversion word when logging exceptions.
  • PID : It defines the current process ID.


  • Initial Setup:

Spring Boot provides a web tool called Spring Initializer to bootstrap an application quickly.


  • Dependencies:

We won’t need any additional dependencies for configuring logger in Spring boot web application. All the dependency are present in the spring boot after from version 1.2.0. SLF4j dependency is included in the Spring Boot by default. For a web application, you need only spring-boot-starter-web, since it depends transitively on the logging starter.

  • Project Structure.

Below is the project Structure of the project. For this demo, we are creating an application that has the following dependency.

Spring Boot Logger Configuration Example
Spring Boot Logger Configuration Example




  • application.properties:

To enable logging, create an application.properties file in the root of the resources folder.

  • application.yml

 Start the application. Access application at the browser and verify log messages in the console.

The code used in these examples can be found on my GitHub

1 Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Show Buttons
Hide Buttons