Spring Boot
Logging Configuration
Environment Variables
Application Properties
Log Level

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:

  1. TRACE: fine-grained events, most useful for debugging.
  2. DEBUG: detailed information about the application flow.
  3. INFO: the default; standard output showing application progress.
  4. WARN: unexpected or undesirable situations that are not necessarily errors.
  5. ERROR: significant problems that may halt the application or a component.
  6. FATAL: very severe errors that will presumably make the application abort. Logback has no FATAL level and maps it to ERROR.

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

bash
   export LOGGING_LEVEL_ROOT=DEBUG

One package

To set com.example.service to TRACE:

bash
   export LOGGING_LEVEL_COM_EXAMPLE_SERVICE=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:

dockerfile
# Dockerfile example
ENV LOGGING_LEVEL_ROOT=DEBUG

or when starting the container:

bash
docker run -e LOGGING_LEVEL_ROOT=INFO my-spring-boot-app

System properties override environment variables

A JVM system property takes precedence over an environment variable. The property name is the logging.level.* form:

bash
java -Dlogging.level.root=ERROR -jar myapp.jar

Precedence, highest first:

  1. System properties (e.g., via -D flags)
  2. Environment variables
Configuration ApproachExampleApplicable ScopeOverrides
Logging Level RootLOGGING_LEVEL_ROOT=DEBUGEntire ApplicationYes, via system properties
Package-Specific LoggerLOGGING_LEVEL_COM_EXAMPLE_SERVICE=TRACESpecific Package/NamespaceYes, via system properties
Docker Environment Variable-e LOGGING_LEVEL_ROOT=INFOContained Application InstanceSystem properties in container
System Property-Dlogging.level.root=ERRORJVM InstanceHighest precedence

Course
Beginner
27 lessons
10 hours
System Design Fundamentals

Build a strong foundation in designing scalable, reliable distributed systems.

View the course
System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design