spring-boot default log location
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Introduction
A frequent Spring Boot logging question is: "Where are my logs written by default?" The short answer is that Spring Boot logs to the console by default and does not create a log file unless you configure one. This surprises teams coming from app servers where file logging is preconfigured.
Understanding default behavior and explicit file configuration is important for production deployment, especially in containers and Kubernetes where log routing strategy affects observability and retention.
Core Sections
1. Default logging behavior in Spring Boot
Out of the box, Spring Boot configures a logging system (typically Logback) and writes application logs to standard output.
Run the app and logs appear in terminal. No file is created unless you set a file property or custom logback appender.
2. Configure log file name and location explicitly
In modern Spring Boot, use:
logging.file.nameto set full file path/name.logging.file.pathto set directory for default file naming.
Or:
If the directory is not writable, file logging fails or silently falls back depending on environment and logging backend configuration. Always verify permissions at deploy time.
For custom rolling policies, define logback-spring.xml.
3. Production strategy: console vs file in containers
In Kubernetes and most container platforms, best practice is usually console logging plus centralized collection (Fluent Bit, CloudWatch, ELK, etc.). Writing local files inside ephemeral containers often complicates retention and rotation.
If you do require files (compliance, sidecar tailing, legacy integration), mount persistent volumes and configure rotation. Test startup behavior when disk is full or path is missing.
Use environment variables to control location per environment:
Spring Boot maps uppercase underscore env vars to property names.
Common Pitfalls
- Assuming Spring Boot writes a file by default when it only logs to console initially.
- Using deprecated/old property names from outdated examples without checking current Boot version.
- Configuring file path to non-writable directories and missing startup/runtime log errors.
- Writing logs to container filesystem without retention strategy in orchestrated environments.
- Mixing custom
logback.xmland application properties in conflicting ways.
Summary
Spring Boot’s default log location is standard output, not a file. Set logging.file.name or logging.file.path when file logging is required, and use logback-spring.xml for advanced rotation policies. In containerized systems, prefer console logs with centralized aggregation unless there is a strong reason to persist local log files.
For enterprise environments, standardize logging configuration per environment profile. Development may prefer colorful console output, while production may require JSON-formatted logs for ingestion into observability platforms. Keep these variants in profile-specific configuration or conditional logback appenders, and verify startup behavior in each environment. Consistency here reduces "works locally" logging surprises.
Also include correlation identifiers (request IDs, trace IDs) in your log pattern early. Log location is only part of the observability story; log context quality determines whether incidents are diagnosable. Even with perfect file placement, logs without trace context are harder to use during high-pressure debugging.
Treat logging setup as deploy-time infrastructure, not an afterthought, and review it alongside tracing and metrics configuration.
A quick startup smoke test that confirms expected destination and rotation behavior can prevent difficult production logging incidents.
This small discipline pays off quickly in incident response.
Related reading
- spring-boot health not showing details withDetail info
- Spring-Boot logging to Kafka how to eliminate warning; best practices
- Spring-Boot logging with log4j2?
- Spring Actuator + Kafka Streams - Add kafka stream status to health check endpoint
- Spring-boot default profile for integration tests
- Spring-boot default profile for integration tests
- Spring actuator's liveness and readiness are returning 404
- Spring and scheduled tasks on multiple instances

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.