Set the Spring Boot logging level with an environment variable
Codemia Knowledge Hub ·
Set a LOGGING_LEVEL_ variable in the environment, followed by the logger name. LOGGING_LEVEL_ROOT=DEBUG sets the root logger, and LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_WEB=DEBUG sets org.springframework.web. Spring Boot's relaxed binding maps these variables to the logging.level.* properties, so you can change verbosity per environment without editing application.properties or rebuilding the application.
Log levels
From most to least verbose:
- TRACE: fine-grained events, most useful for debugging.
- DEBUG: detailed information about the application flow.
- INFO: the default; standard output showing application progress.
- WARN: unexpected or undesirable situations that are not necessarily errors.
- ERROR: significant problems that may halt the application or a component.
- FATAL: very severe errors that will presumably make the application abort. Logback has no
FATALlevel and maps it toERROR.
Spring Boot also accepts OFF.
Environment variable names
The variable name is LOGGING_LEVEL_ followed by ROOT or by the package name in upper case, with dots replaced by underscores.
Root logger
One package
To set com.example.service to TRACE:
This only works at package level. Relaxed binding always lowercases environment variables, so you cannot target an individual class this way. For a single class, use the SPRING_APPLICATION_JSON variable instead.
Making the variable visible to the application
The variable must exist in the environment that runs the application: the host operating system, or the orchestration system (such as Docker or Kubernetes) that deploys it. The level is read at startup, so a changed variable takes effect when the application restarts.
Docker
Set it in the Dockerfile:
or when starting the container:
System properties override environment variables
A JVM system property takes precedence over an environment variable. The property name is the logging.level.* form:
Precedence, highest first:
- System properties (e.g., via
-Dflags) - Environment variables
| Configuration Approach | Example | Applicable Scope | Overrides |
| Logging Level Root | LOGGING_LEVEL_ROOT=DEBUG | Entire Application | Yes, via system properties |
| Package-Specific Logger | LOGGING_LEVEL_COM_EXAMPLE_SERVICE=TRACE | Specific Package/Namespace | Yes, via system properties |
| Docker Environment Variable | -e LOGGING_LEVEL_ROOT=INFO | Contained Application Instance | System properties in container |
| System Property | -Dlogging.level.root=ERROR | JVM Instance | Highest precedence |
Related reading
- Set node label to the pod environment variable
- Set root logging level in application.yml
- Set value in dependency of Helm chart
- Setting a log file name to include current date in Log4j
- Set object property using reflection
- Setting active profile and config location from command line in Spring Boot
- setting image pull policy using kubectl
- Setting queueSize parameter for ch.qos.logback.classic.AsyncAppender
System design interview problems on this topic
- Design a Metrics Monitoring and Alerting System: solution and walkthrough
- Design a Distributed Tracing System: solution and walkthrough
- Design a Code Deployment System: solution and walkthrough
- Design GitHub Actions: solution and walkthrough

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseSystem Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.