Spring Logging

This is written mostly from theory but with a little bit of experience. My initial query was how do I set the logging level within a Spring batch application. This was more difficult as the Spring Batch was running in a Kubernetes cluster, however in order to understand how to make the change there, you first need to know how Spring works!

The principle is that you need to set the level for a given package, rarely would you turn it on for everything! If you did want this then "logging.level.=DEBUG" would do the trick, but note that second full stop, however you are more likely to want to debug your own code, so "logging.level.com.geoffdoesstuff=DEBUG" would get all my code output debug messages but I could be more specific. Alternatively "logging.level.org.springframework=DEBUG" will get Spring showing you all its debug. The next things to consider is the order of precedence when setting the logging levels:

  1. Environment Variable
  2. JVM Parameter (-D)
  3. Profile
  4. File

It is worth noting though that environment variables work with _ (underscore) rather than . (full stop).