使用application.properties将Spring Boot中logback.xml的位置外部化 [英] Externalized the location of logback.xml in Spring Boot using application.properties

查看:267
本文介绍了使用application.properties将Spring Boot中logback.xml的位置外部化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用application.properties在Spring Boot中自定义logback.xml的位置?

How can I customized the location of logback.xml in Spring Boot using application.properties?

我试过以下但是没有用。

I tried below but is not working.

application.properties

application.properties

logging.config = /home/dev-01/Documents/logback.xml

如果logback.xml位于资源文件夹中,则它正在工作,但如果它位于项目之外,则无效。

It is working if the logback.xml is located in the resource folder, but not working if it is located outside the project.

如果我提供环境变量,它也可以工作,如

It is also working if the I supply as environment variable like

-Dlogging.config=/home/dev-01/Documents/logback.xml


推荐答案

下面的构造对我有用(但是我使用相对路径而不是绝对路径):

Below construct worked for me (but I used relative path instead of absolute):

logging.config=file:/home/dev-01/Documents/logback.xml

这篇关于使用application.properties将Spring Boot中logback.xml的位置外部化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆