我用的是spring boot,想把logback.xml文件放在classpath之外,这样修改logback.xml的内容就方便多了。我使用的是 Windows 10,logback.xml 文件的位置是:
C: pache-tomcat-9.0.37-50099
我确实在 application.yaml 中指定了这个位置,就像这样
logging:
config: "C:/apache-tomcat-9.0.37-50099/logback.xml"
但是spring没有找到logback.xml的位置,因为没有创建日志文件。 如何指定 logback.xml 文件的位置?
第一次点击“logback.xml 应该去哪里”给了我
https://dzone.com/articles/logback-configuration-using-xml
对于通过 XML 进行的 Logback 配置,Logback 需要类路径中的 Logback.xml 或 Logback-test.xml 文件。在 Spring Boot 应用程序中,您可以将 Logback.xml 文件放在资源文件夹中。如果您的 Logback.xml 文件在类路径之外,您需要使用 Logback.configurationFile 系统属性指向它的位置,就像这样。
-DLogback.configurationFile=/path/to/Logback.xml
我们的配置使用不同的属性:
-Dlogging.config=file:///your/file/location/logback.xml
希望它能帮助路过的人。