2

I'm using logback configuration for my spring boot based RESTful service. Some of my logging configuration properties reside in Consul's KV store (like, smtp host). I'm also using "spring-cloud-starter" in my project for hystrix configuration.

For the configuration, I'm using "logback-spring.xml" so that I've access to spring context in the logback configuration via "springProperty" tag.

Now, my problem is, at the time of bootstrap, BootstrapApplicationListener is invoked which reads all the bootstrap resources (bootstrap.properties) and loads the Logging System. At this point, the Consul configurations (ConsulAutoConfiguration) have not been loaded, due to which, the required logging configuration is not found, hence, the logback is not initialized properly.

Is there a way to get the Consul configuration loaded before or during execution of BootstrapApplicationListener so that the logging system initializes properly?

Alternatively, is there any other way to just reset the logging system after the Consul properties are read?

Thanks.

Shailesh
  • 61
  • 2
  • 8
  • There may be a chicken and egg problem. Are you using spring-cloud-starter-consul-config (or -all)? – spencergibb Jan 25 '17 at 00:04
  • Yes, I'm using spring-cloud-starter-consul-config. – Shailesh Jan 26 '17 at 06:06
  • 1
    Bootstrap `BootstrapApplicationListener` was created to load remote properties, so they can't come before then. There is a https://github.com/spring-cloud/spring-cloud-commons/blob/master/spring-cloud-context/src/main/java/org/springframework/cloud/logging/LoggingRebinder.java that updates the loggers if a `logging.level.*` key has changed. Maybe you could write something similar? – spencergibb Jan 26 '17 at 20:53
  • Thanks @spencergibb. That's what I wanted to know. I was just wondering if there a way around by using defaults. But, as it turns out, I'll have to write something custom for it. Thanks again. – Shailesh Jan 30 '17 at 09:39

0 Answers0