Default logging file for spring boot application
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Spring Boot is a popular framework for developing Java-based applications and provides excellent support for logging. Logging in Spring Boot is primarily designed to be simple to configure and use, making it easy for developers to diagnose issues by examining log output. This article will focus on the default logging file behavior in a Spring Boot application, exploring the technical details, customization options, and practical examples.
Overview of Logging in Spring Boot
Spring Boot uses Apache Commons Logging for all internal logging but allows developers to configure the underlying logging system they prefer. By default, Spring Boot will configure itself sensibly based on the jars present on the classpath.
Supported Logging Frameworks
Spring Boot supports several logging frameworks out of the box, including:
- Logback (default)
- Log4j2
- Java Util Logging (JUL)
The default choice of Logback is due to its performance, flexibility, and broad adoption within the Java ecosystem.
Default Logging Configuration
By default, a Spring Boot application logs only to the console with `INFO` level messages. If you want logging to go to a file, you need to adjust the default settings.
Default Logging File Behavior
Spring Boot’s default behavior when it comes to logging to a file includes:
- Writing logs to a file named `spring.log` located in the current directory.
- Rolling over the log file when it reaches a specified size limit.
- Deleting archived log files according to a predefined policy.
Configuration File
To customize the default behavior, you can utilize the `application.properties` or `application.yml` files, where you can define various logging properties. Here’s a quick look at default configurations and how you might override them:
Application Properties Example
- Persistence: Logs stored in files remain available after application restarts or failures.
- Analysis: Easier to perform historical analysis and track trends over time.
- Audit: Maintains an audit trail of application behavior and user actions.

