无法从Consul加载logback.xml [英] Not able to load logback.xml from Consul

查看:203
本文介绍了无法从Consul加载logback.xml的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题是这样的

我在Consul KV商店
中拥有了该项目的所有配置,该配置包括application.yml,logback.xml和项目需要的其他一些配置。

I have all my configuration for the project in Consul KV store The configuration includes application.yml, logback.xml and few other configurations needed by my project.

使用bootstrap.yml进行Spring Cloud Consul配置,其中包含
logging.config和配置$ b的URI $ b URI如下用于logging.config- http:// CONSUL_SERVER_IP:CONSUL_SERVER_PORT /v1/kv/CONSUL_CONFIG_PREFIX/logback.xml?raw

Using bootstrap.yml for Spring Cloud Consul configuration which contains logging.config for with the URI of the configuration URI is as follow for logging.config - http://CONSUL_SERVER_IP:CONSUL_SERVER_PORT/v1/kv/CONSUL_CONFIG_PREFIX/logback.xml?raw

还尝试在下面作为参数/ VM参数传递

Also tried passing below as argument/VM argument

-Dlogging.config=http://CONSUL_SERVER_IP:CONSUL_SERVER_PORT/v1/kv/CONSUL_CONFIG_PREFIX/logback.xml?raw

需要查询字符串'raw'才能获取实际的配置文件。

Query string 'raw' is needed to get the actual config file.

执行应用程序时它给出了以下错误

While executing the application it gives the following error


原因:ch.qos.logback.core.LogbackException:意外的文件名
文件
的扩展名[ http:// CONSUL_SERVER_IP:CONSUL_SERVER_PORT / v1 / kv / CONSUL_CONFIG_PREFIX / logback.xml?raw]

处应为.groovy或.xml ch.qos.logback.classic.util.ContextInitializer.configureByResource(ContextInitializer.java:77)在
org.springframework处为
。 boot.logging.logback.LogbackLoggingSystem.configureByResourceUrl(LogbackLoggingSystem.java:180)
at
org.springframework.boot.logging.logback.LogbackLoggingSystem.loadConfiguration(LogbackLoggingSystem.java:149)
。 .. 30 more

Caused by: ch.qos.logback.core.LogbackException: Unexpected filename extension of file [http://CONSUL_SERVER_IP:CONSUL_SERVER_PORT/v1/kv/CONSUL_CONFIG_PREFIX/logback.xml?raw]. Should be either .groovy or .xml at ch.qos.logback.classic.util.ContextInitializer.configureByResource(ContextInitializer.java:77) at org.springframework.boot.logging.logback.LogbackLoggingSystem.configureByResourceUrl(LogbackLoggingSystem.java:180) at org.springframework.boot.logging.logback.LogbackLoggingSystem.loadConfiguration(LogbackLoggingSystem.java:149) ... 30 more

Spring boot version-2.0.1.RELEASE

Spring boot version - 2.0.1.RELEASE

春季云版本-Finchley.SR2

Spring cloud version - Finchley.SR2

经典经典版本和核心版本-1.2.3

logback classic and core version - 1.2.3

推荐答案

以下解决方案对我有用。只需更改bootstrap.yml中或作为VM参数传递给logging.config的URI

Following solution, worked for me. Just change the URI passed to logging.config in bootstrap.yml or as VM arguments

http://CONSUL_SERVER_IP:CONSUL_SERVER_PORT/v1/kv/CONSUL_CONFIG_PREFIX/logback.xml?raw=true&xml

如果您遇到类似的问题,将& fileExtension 添加到URI

If you have a similar issue then add &fileExtension to the URI

这篇关于无法从Consul加载logback.xml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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