we are now using the spring boot version is 1.5.13.RELEASE, and the spring cloud version is Edgware.SR3, and the spring cloud config version is 1.4.3.RELEASE。
And we use the eureka 1.7.2 as our registry center, and the config-server and the config-client is the eureka-client.
when we think that, since the spring cloud config is the config server and it should be manage any type of configs of our app. so we put the logback.xml to the github and refer to the spring cloud doc, the we can get the logback.xml in the config-client by setting the
logging.config=${spring.cloud.config.uri}/*/default/master/logback.xml.
however, since the config-server and the config-client is the eureka-server's client, it should use the service name to communicate. and we set the config int the bootstrap.properties of the config-client like that:
spring.cloud.config.name=logback
spring.cloud.config.profile=default
spring.cloud.config.label=master
spring.cloud.config.discovery.enabled=true
spring.cloud.config.discovery.service-id=config-server-name
eureka.client.serviceUrl.defaultZone=http://admin:admin@localhost:7001/eureka/
but, when we start the config-client, the config-server occurs an error that:
java.lang.IllegalStateException: Failed to load property source from location 'file:/D:/others/test/configBack/qing-cloud-m1-config/logback-spring.xml'
Caused by: java.util.InvalidPropertiesFormatException: org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 16; 文档根元素 "configuration" 必须匹配 DOCTYPE 根 "null"。
at sun.util.xml.PlatformXmlPropertiesProvider.load(PlatformXmlPropertiesProvider.java:80)
at java.util.Properties$XmlSupport.load(Properties.java:1201)
at java.util.Properties.loadFromXML(Properties.java:881)
at org.springframework.core.io.support.PropertiesLoaderUtils.fillProperties(PropertiesLoaderUtils.java:136)
at org.springframework.core.io.support.PropertiesLoaderUtils.loadProperties(PropertiesLoaderUtils.java:121)
at org.springframework.boot.env.PropertiesPropertySourceLoader.load(PropertiesPropertySourceLoader.java:44)
at org.springframework.boot.env.PropertySourcesLoader.load(PropertySourcesLoader.java:128)
at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.doLoadIntoGroup(ConfigFileApplicationListener.java:490)
at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.loadIntoGroup(ConfigFileApplicationListener.java:473)
... 87 common frames omitted
so how can I solved this problem, and the spring cloud config cannot store xml or another type file? if so, there maybe much limits of it
I read the source code and found that it may be can load xml file but why that problems occurs
public static void fillProperties(Properties props, Resource resource) throws IOException {
InputStream is = resource.getInputStream();
try {
String filename = resource.getFilename();
if (filename != null && filename.endsWith(XML_FILE_EXTENSION)) {
props.loadFromXML(is);
}
else {
props.load(is);
}
}
finally {
is.close();
}
}
the logback.xml is below and it cloud be execute in a standalone spring boot project ```
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>${ENCODER_PATTERN}</pattern>
</encoder>
</appender>
<appender name="FILE-APPENDER" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>../../log/${LOG-NAME}.%d{yyyy-MM-dd}.log</fileNamePattern>
</rollingPolicy>
<encoder>
<pattern>${ENCODER_PATTERN}</pattern>
</encoder>
</appender>
<logger name="cn.jz" additivity="false" level="DEBUG">
<appender-ref ref="CONSOLE" />
<appender-ref ref="FILE-APPENDER"/>
</logger>
<root level="DEBUG">
<appender-ref ref="CONSOLE" />
</root>
```