Spring Boot Logging Levels Configuration & Properties |Video upload date:  · Duration: PT22M39S  · Language: EN

Practical guide to Spring Boot logging levels configuration starter properties patterns paths and debug options for clearer logs

So your app is noisy at 3 AM and you need to stop the chaos without reinventing the JVM or sacrificing your sleep. This guide walks through Spring Boot log levels, application properties and starter behavior with a healthy dose of sarcasm and zero mystery. You will learn how to set sensible defaults, silence the drama queens in third party libs and enable fine grained debug when an incident screams for attention.

Understand logging levels and when to use them

Logging levels are the traffic lights of runtime troubleshooting. Use them well and you find the bug. Use them badly and you spend nights chasing stack traces from libraries you never meant to care about.

  • TRACE - The tiny font under the microscope. Use only when you need every step logged.
  • DEBUG - Useful for dev time and careful detective work.
  • INFO - Baseline for normal application events and startup messages.
  • WARN - Things to watch but not panic about yet.
  • ERROR - Real problems that need attention.
  • OFF - Silence. May be used in extreme cases where logging is a performance hog.

Tip - prefer package specific levels over global TRACE. Silence noisy libraries with WARN while elevating detail for the package under investigation. This keeps logs useful and your pager less grumpy.

Configure application properties the boring and correct way

Spring Boot reads properties from application.properties or application.yml by default. Set a global level and then raise or lower detail per package. No rebuild required for most runtime changes if you use environment or JVM properties.

logging.level.root=INFO
logging.level.com.example=DEBUG
logging.file.name=application.log
logging.file.path=/var/log/myapp

The first line sets a sensible baseline. The second line gives extra detail for your app package while leaving third party libs quieter. Use logging.file.name or logging.file.path based on whether you want a specific filename or a directory.

Manage the logging starter and alternatives

Spring Boot includes spring-boot-starter-logging out of the box which wires up Logback. Keep it if you like sane defaults and a small learning curve. If you need fancier features switch to a Log4j2 starter but know that you then change config formats and behavior.

  • Keep spring-boot-starter-logging for default Logback support and simple configuration
  • Replace it with a Log4j2 starter for advanced appenders and filters
  • Removing or swapping starters changes which files Spring Boot will load at startup

Customize console and file patterns

Patterns control timestamp format, thread name, level, logger and message. Make them readable for humans and parsable for log collectors. Here is a minimal console pattern that works well.

logging.pattern.console=%d{yyyy-MM-dd HH:mm:ss} - %level - %logger - %msg%n

Adjust the date format and included fields to suit your log aggregation tool. If you write to files make sure the runtime container has write permission to the target path.

Use runtime overrides for fast debugging

When production misbehaves avoid rebuilding the artifact. Override properties at JVM startup or via environment variables. Those take precedence over the packaged application properties which is perfect for urgent investigations.

  • JVM system property example to enable trace for one package
    -Dlogging.level.com.example=TRACE
  • Command line or environment variables work too and are great for containers and cloud deployments

Quick troubleshooting checklist

  • Set root to INFO and enable DEBUG only for the package under test
  • Use logging.file.name for a specific filename or logging.file.path for a directory layout
  • Keep spring-boot-starter-logging unless you need Log4j2 features
  • Prefer structured logs or a stable pattern when using log collectors
  • When you are done debugging return levels to sane values so your disk and inbox survive

Follow these steps and you will have clearer logs, faster investigations and fewer midnight calls. If that sounds like magic it is not. It is just good properties and the occasional stern glare at noisy libraries.

I know how you can get Azure Certified, Google Cloud Certified and AWS Certified. It's a cool certification exam simulator site called certificationexams.pro. Check it out, and tell them Cameron sent ya!

This is a dedicated watch page for a single video.