vendredi 3 avril 2015

spring boot, logback and logging.config property

I am implement logging in a spring boot project with logback library. I want to load different logging configuration files according to my spring profiles (property 'spring.pofiles.active'). I have 3 files : logback-dev.xml, logback-inte.xml and logback-prod.xml. I am using spring boot version 1.2.2.RELEASE.


As you can read in spring boot documentation (here). It says :



The various logging systems can be activated by including the appropriate libraries on the classpath, and further customized by providing a suitable configuration file in the root of the classpath, or in a location specified by the Spring Environment property logging.config. (Note however that since logging is initialized before the ApplicationContext is created, it isn’t possible to control logging from @PropertySources in Spring @Configuration files. System properties and the conventional Spring Boot external configuration files work just fine.)



So I tried to set 'logging.config' property in my application.properties file :



logging.config=http://classpath:/logback-${spring.profiles.active}.xml


But when i start my application, my logback-{profile}.xml is not loaded...


I think logging is a common problem that all projects using spring boot have encourtered. I want to know if I am in the right direction or not because I have other solutions that works too but i find them not elegant (conditionnal parsing with Janino in logback.xml file or command line property).


Thanks for your futur answers and feedbacks!


Aucun commentaire:

Enregistrer un commentaire