Default logging file for spring boot application
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
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.
Related reading
- Default private registry in Docker
- Defaulted container container-1 out of container-1, container-2
- Delete all files in directory (but not directory) - one liner solution
- Deploy a .NET Windows Service with Amazon Elastic Beanstalk with no Web Application
- Default maximumPoolSize for HikariCP
- Default value of 'boolean' and 'Boolean' in Java
- Deploy a project using Git push
- Deploy nginx-ingress in aks without rbac issue

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.