Spring Cloud配置服务器不遵循logging.file属性并且不记录外部文件

问题描述

我正在使用spring-boot-starter 2.3.3.RELEASE版本。我正在本机配置文件中运行我的spring cloud配置服务器(正在文件系统中查找配置文件)。我加了 application.properties文件中的logging.file = /var/log/config.log。但是我的应用程序没有将日志记录到该文件中(所有其他微服务都记录到该位置)。我会缺少Spring Cloud配置服务器的任何其他设置吗?非常感谢您的帮助。

解决方法

在spring boot 2.3.3 RELEASE文档中,使用属性指示指定位置的日志记录属性:

logging.file.path={path}

文档: https://docs.spring.io/spring-boot/docs/2.3.3.RELEASE/reference/htmlsingle/#boot-features-logging-file-output

从logging.path到logging.file.path的这种修改在Spring Boot 2.2中似乎已弃用: https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.2-Release-Notes#deprecations-in-spring-boot-22

,

使用spring-boot应用程序执行此操作的一种方法是,将命令行参数设置为默认值,它将在控制台上转储所有内容。

logging.file=logs/test.log

老派,但效果很好,请在application.properties中保存路径

logging.file=logs/test.log