Spring-boot: logging.config failed to load file from secured http server.

Created on 10 Jun 2016  路  9Comments  路  Source: spring-projects/spring-boot

Hi,

I'm try to use logging.config with a remote logback.xml file which is served by a secured spring cloud config server. I got the following error


... -jar my.jar server --logging.config=http://toto:toto@localhost:8888/myapp/local/develop/logback.xml
...
Logging system failed to initialize using configuration from 'http://toto:toto@localhost:8888/myapp/local/develop/logback.xml'
java.io.IOException: Server returned HTTP response code: 401 for URL: http://toto:toto@localhost:8888/myapp/local/develop/logback.xml

As I can see in the LogginApplicationListener.initializeSystem method, Spring uses the util ResourceUtils.getURL(logConfig).openStream().close(); to load the file which instantiate URL class.


try {
            // try URL
            return new URL(resourceLocation);
        }

It could be nice if the LogginApplicationListener supports HTTP basic authentication for http logging.config URL.

Regards,

declined

Most helpful comment

People need to centralize all sorts of critical stuff to a config server. I'm not sure logger config files should be critical (I wouldn't want my app to not start if it wasn't available), but I can see that might be a valid choice. We should be able to switch to using a ResourceLoader to resolve the config file (I'm quite surprised it isn't implemented that way already), but we should be cautious about what to do if it fails. Maybe give the option to fail fast, but by default ignore it?

All 9 comments

I'm not sure that loading a remote logback.xml isn't something we anticipated happening, I don't think it's a great idea personally. Perhaps @dsyer or @spencergibb might have more thoughts about it.

I'm not too keen add more complexity to the LoggingSystem class unless it's absolutely necessary.

Hi @philwebb

I'd like to load logback.xml file from spring-config-server. This why I tried this. You say this is not a good thing. In your opinion what's wrong?

What is the better approach to decentralize all configuration file like logging configuration?

In our project logback configuration depends on the environment.

Regards

@RaphC The logging system gets initialized pretty early and is obviously needed to correctly report errors. If the remote endpoint isn't available for some reason I'm not sure how well we'd deal with that.

That's just my gut instinct. I'd really want some input from the Spring Cloud team who are much more familiar with the perils of loading data from remote systems.

We've had a few people ask to load logging configuration from config server (I think some are actually doing it, but obviously don't have http basic auth).

People need to centralize all sorts of critical stuff to a config server. I'm not sure logger config files should be critical (I wouldn't want my app to not start if it wasn't available), but I can see that might be a valid choice. We should be able to switch to using a ResourceLoader to resolve the config file (I'm quite surprised it isn't implemented that way already), but we should be cautious about what to do if it fails. Maybe give the option to fail fast, but by default ignore it?

Hello everyone,

I better understand the reason about not critical stuff and the difficulty to deal with a failure of file's updload.

I like the option of fast failure because in certain case it could be critical. Logging can become of important piece of an application. Concerning our application we are using spring ampq appender to send metrics. So if the logback file isn't available we can't monitoring our apps.

Regards

I would like that feature too or a native way for logging to be fetched from the config server without any complicated configuration.

I think this issue should really live in https://github.com/spring-cloud/spring-cloud-config. I'm still not keen for us to make the core Spring Boot logging code any more complex than it already is.

Last word: I don't really understand the problem. If you need to authenticate to a server to fetch a logger config file, you probably need to think again about some of the choices you made to get to that point. If I'm missing something, feel free to open an issue, as Phil suggests, in Spring Cloud.

Was this page helpful?
0 / 5 - 0 ratings