Skip to content
Advertisement

How to set logging.path for spring-boot apps?

spring-boot provides several logging.* settings that can be applied in application.properties, like:

logging.level.=DEBUG
logging.file=myfile.log
logging.path=d:/logs/

Problem: myfile.log is generated, BUT inside the classpath! Why isn’t spring taking my absolute path into account?

Advertisement

Answer

The Spring Boot documentation states

By default, Spring Boot will only log to the console and will not write log files. If you want to write log files in addition to the console output you need to set a logging.file or logging.path property (for example in your application.properties).

and then describes how the logging.file and logging.path properties work. You should only set one.

If logging.file is set, it will write to that specific file. The documentation states

Names can be an exact location or relative to the current directory.

So you’re likely writing to your current directory, which happens to be the same as your classpath.

If you set logging.path, Spring Boot

Writes spring.log to the specified directory. Names can be an exact location or relative to the current directory.

Check that your current directory isn’t your classpath, if you don’t want them to mix, and adapt one of the logging.file and logging.path accordingly.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement