Not able to load logback.xml from Consul

守給你的承諾、 提交于 2019-12-11 19:50:05

问题


The issue goes like this

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.

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

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

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

While executing the application it gives the following error

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 cloud version - Finchley.SR2

logback classic and core version - 1.2.3


回答1:


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

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



来源:https://stackoverflow.com/questions/53846374/not-able-to-load-logback-xml-from-consul

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!