我不再确定 Spring-boot 到底如何处理环境、属性文件和配置位置。
用例
下面是我的 spring-boot 应用程序的结果 docker 容器
Docker 容器
/
|- spring-boot-app.jar
|- /config/
|--|- application.properties
|--|- logback-spring.xml
我还使用环境变量
问题
Spring-boot 不会读取 logback-spring.xml
。
为了做到这一点,我必须添加 LOGGING_CONFIG=config/logback-spring.xml
Spring-boot 不应该在这个目录下自动查找 logback-spring.xml 吗?
谢谢
最佳答案
在 Spring 文档 (https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-logging.html) 中,它说:
The various logging systems can be activated by including the appropriate libraries on the classpath, and further customized by providing a suitable configuration file in the root of the classpath, or in a location specified by the Spring Environment property logging.config.
因此,如果您将文件直接放在 spring-boot-app.jar 下,它应该无需配置 logging.config
即可工作。
关于java - spring-boot 和 ./config 目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46649085/