Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 757
membersound Avatar asked Dec 01 '16 14:12

membersound


1 Answers

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.

like image 105
davidxxx Avatar answered Sep 18 '22 06:09

davidxxx