Log management in Spring Boot

Logging is for sure not a glamorous subject, but it’s a critical one - at least for DevOps and Ops teams. While there are plenty of material on the Web describing how to change your ASCII banner, there is not much on how to efficiently manage the log output.

By default, Spring Boot will output log on the console and not use any file at all.

However, it’s possible to tell Spring Boot to log in an output file. At the simplest level, the path where Spring Boot will put the spring.log file can be easily configured in the application.properties under the logging.path key:


Note that another alternative is to use the logging.file key in order to not only set the file path but also the file name.


While this works very well for development purposes, it’s not an acceptable process for the Ops team to unzip the final jar, update the application.properties file and repackage it - this for each and every different environment.

Spring Boot allows to override the value set in the packaged file (if any) on the command-line as a standard system property when launching the jar:

java -jar -Dlogging.path=/tmp  myapp.jar

Finally, it’s also possible to override this value when invoking the Spring Boot Maven plugin on the command line. However, directly using the system property doesn’t work for the plugin will spawn another JVM. One has to use the run.jvmArguments system property and delegate it the wanted value:

mvn spring-boot:run -Drun.jvmArguments="-Dlogging.path=/tmp"

Note that this works for every available property!

Nicolas Fränkel

Nicolas Fränkel

Developer Advocate with 15+ years experience consulting for many different customers, in a wide range of contexts (such as telecoms, banking, insurances, large retail and public sector). Usually working on Java/Java EE and Spring technologies, but with focused interests like Rich Internet Applications, Testing, CI/CD and DevOps. Also double as a trainer and triples as a book author.

Read More
Log management in Spring Boot
Share this