samedi 28 mars 2015

Unable to use Spring EL in logbook.xml

I have a Spring boot console app using Logback. All of the properties (for the app as well as for Logback) are externalized into a standard application.properties file in the classpath. These properties are picked up just fine in the app itself, but are not picked up in the logback.xml file. It appears as though the logback.xml is processed before Spring Boot fires up, therefore the EL placeholders are not processed.


Using the FileNamePattern as an example, in the application.properties, I have something like this:



log.filePattern=/%d{yyyy/MM-MMMM/dd-EEEE}


and in logback.xml, I'll have this:



<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<FileNamePattern>${log.logDirectory}${log.filePattern}.log
</FileNamePattern>
</rollingPolicy>


When running the app, I'll see errors such as:



ERROR in ch.qos.logback.core.joran.spi.Interpreter@24:25 -
RuntimeException in Action for tag [rollingPolicy]
java.lang.IllegalStateException: FileNamePattern
[log.logDirectory_IS_UNDEFINEDlog.filePattern_IS_UNDEFINED.log]
does not contain a valid DateToken


Similar code works just fine in other Spring (not Spring Boot) apps, so I'm curious if Spring Boot just behaves a bit differently.


Thanks!


Aucun commentaire:

Enregistrer un commentaire