Shorn
Shorn

Reputation: 21446

why doesn't spring-boot listen to the logging.path variable?

Using spring-boot 1.2.3.RELEASE.

The only way I can get spring-boot to log to a specific directory is by setting the "log.file" property like so:

logging.file=/var/log/app.log

But as far as I can tell, according to the docs, I should be doing:

logging.file=app.log
logging.path=/var/log

But it just doesn't seem to listen to the logging.path property, it will just write the file to the current directory.

Are the docs wrong or is there something really obvious I'm missing here?

Also, with this setting, it's still going to do log rolling properly, right?

Upvotes: 38

Views: 28394

Answers (4)

afshar
afshar

Reputation: 703

using spring 2.4.5

this is work

logging.file.path=./log/
logging.file.name=${logging.file.path}mylog.txt

or

logging.file.name=./log2/mylog.txt

in summary

logging.file.path=.             # write logs to the current directory
logging.file.path=/home/logs    # write logs to /home/logs
logging.file.path=/mnt/logdir   # write logs to /mnt/logdir

for Spring Boot 1.x : set logging.path

Upvotes: 5

K D
K D

Reputation: 51

In application.properties, just use the below variable

logging.file.path={--your file path--}

Upvotes: 1

ZoomAll
ZoomAll

Reputation: 473

Variables path and file can be used simultaneously in the following ways (application.yml):

logging:
  path: /var/log/
  file: ${logging.path}app.log

As a result, spring-boot will keep a log in the file /var/log/app.log

Upvotes: 8

Mithun
Mithun

Reputation: 8067

From the documentation:

If you want to write log files in addition to the console output you need to set a logging.file or logging.path property

Spring boot considers either file or path property, not both.

This page has all combinations of file and path properties.

Upvotes: 57

Related Questions