为什么 spring-boot 不监听 logging.path 变量?

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

使用 spring-boot 1.2.3.RELEASE.

让 spring-boot 登录到特定目录的唯一方法是像这样设置 "log.file" 属性:

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

但据我所知,according to the docs,我应该这样做:

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

但它似乎并没有听logging.path 属性,它只是将文件写入当前目录。

文档是错误的还是我在这里遗漏了一些非常明显的东西?

此外,使用此设置,它仍然会正确地进行日志滚动,对吗?

来自文档:

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 引导考虑 filepath 属性,而不是两者。

page 具有 filepath 属性的所有组合。

变量pathfile可以通过以下方式同时使用(application.yml):

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

因此,spring-boot 将在文件 /var/log/app.log

中保留日志

在application.properties中,只需使用下面的变量

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

使用 spring 2.4.5

这是工作

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

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

总结

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