Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Logback configuration live reload (scan=true) with Spring-Boot

Okay guys I am trying to configure a a logback-spring.xml.

My goal is to automatically reload the configuration file upon modification.

So this is what the doc says :

FROM:

<configuration>
  ...
</configuration>

TO:

<configuration scan="true" scanPeriod="30 seconds">
  ...
</configuration>

There is no doubt that if I do not use any elements as :

<springProperty>

OR

<springProfile>

The live reload works with no problems. Also if I am not using the scan="true" springProfile and springProperty are working perfectly as well.

So my conclusion is that spring elements and scan do not like each other. I am getting errors from the type :

16:29:39,101 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@12:125 - no applicable action for [springProperty], current ElementPath  is [[configuration][springProperty]]
16:29:39,102 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@16:109 - no applicable action for [springProperty], current ElementPath  is [[configuration][springProperty]]
16:29:39,102 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@19:64 - no applicable action for [springProperty], current ElementPath  is [[configuration][springProperty]]
16:29:39,103 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@33:29 - no applicable action for [springProfile], current ElementPath  is [[configuration][springProfile]]
16:29:39,103 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@34:70 - no applicable action for [appender], current ElementPath  is [[configuration][springProfile][appender]]
16:29:39,103 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@35:13 - no applicable action for [encoder], current ElementPath  is [[configuration][springProfile][appender][encoder]]
16:29:39,103 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@36:14 - no applicable action for [pattern], current ElementPath  is [[configuration][springProfile][appender][encoder][pattern]]
16:29:39,104 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@38:12 - no applicable action for [append], current ElementPath  is [[configuration][springProfile][appender][append]]
16:29:39,104 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@39:10 - no applicable action for [file], current ElementPath  is [[configuration][springProfile][appender][file]]
16:29:39,104 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@42:70 - no applicable action for [appender], current ElementPath  is [[configuration][springProfile][appender]]
16:29:39,104 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@43:13 - no applicable action for [encoder], current ElementPath  is [[configuration][springProfile][appender][encoder]]
16:29:39,104 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@44:14 - no applicable action for [pattern], current ElementPath  is [[configuration][springProfile][appender][encoder][pattern]]
16:29:39,105 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@46:12 - no applicable action for [append], current ElementPath  is [[configuration][springProfile][appender][append]]
16:29:39,105 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@47:10 - no applicable action for [file], current ElementPath  is [[configuration][springProfile][appender][file]]
16:29:39,105 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@50:70 - no applicable action for [appender], current ElementPath  is [[configuration][springProfile][appender]]
16:29:39,105 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@51:13 - no applicable action for [encoder], current ElementPath  is [[configuration][springProfile][appender][encoder]]
16:29:39,106 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@52:14 - no applicable action for [pattern], current ElementPath  is [[configuration][springProfile][appender][encoder][pattern]]
16:29:39,106 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@54:12 - no applicable action for [append], current ElementPath  is [[configuration][springProfile][appender][append]]
16:29:39,106 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@55:10 - no applicable action for [file], current ElementPath  is [[configuration][springProfile][appender][file]]
16:29:39,106 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@58:70 - no applicable action for [appender], current ElementPath  is [[configuration][springProfile][appender]]
16:29:39,106 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@59:13 - no applicable action for [encoder], current ElementPath  is [[configuration][springProfile][appender][encoder]]
16:29:39,107 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@60:14 - no applicable action for [pattern], current ElementPath  is [[configuration][springProfile][appender][encoder][pattern]]
16:29:39,107 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@62:12 - no applicable action for [append], current ElementPath  is [[configuration][springProfile][appender][append]]
16:29:39,107 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@63:10 - no applicable action for [file], current ElementPath  is [[configuration][springProfile][appender][file]]
16:29:39,107 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@66:70 - no applicable action for [appender], current ElementPath  is [[configuration][springProfile][appender]]
16:29:39,107 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@67:13 - no applicable action for [encoder], current ElementPath  is [[configuration][springProfile][appender][encoder]]
16:29:39,107 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@68:14 - no applicable action for [pattern], current ElementPath  is [[configuration][springProfile][appender][encoder][pattern]]
16:29:39,108 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@70:12 - no applicable action for [append], current ElementPath  is [[configuration][springProfile][appender][append]]
16:29:39,108 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@71:10 - no applicable action for [file], current ElementPath  is [[configuration][springProfile][appender][file]]
16:29:39,108 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@74:53 - no applicable action for [logger], current ElementPath  is [[configuration][springProfile][logger]]
16:29:39,108 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@75:35 - no applicable action for [appender-ref], current ElementPath  is [[configuration][springProfile][logger][appender-ref]]
16:29:39,108 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@78:54 - no applicable action for [logger], current ElementPath  is [[configuration][springProfile][logger]]
16:29:39,108 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@79:35 - no applicable action for [appender-ref], current ElementPath  is [[configuration][springProfile][logger][appender-ref]]
16:29:39,108 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@84:23 - no applicable action for [logger], current ElementPath  is [[configuration][springProfile][logger]]
16:29:39,108 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@85:35 - no applicable action for [appender-ref], current ElementPath  is [[configuration][springProfile][logger][appender-ref]]
16:29:39,109 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@91:37 - no applicable action for [logger], current ElementPath  is [[configuration][springProfile][logger]]
16:29:39,109 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@92:35 - no applicable action for [appender-ref], current ElementPath  is [[configuration][springProfile][logger][appender-ref]]
16:29:39,109 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@95:54 - no applicable action for [logger], current ElementPath  is [[configuration][springProfile][logger]]
16:29:39,109 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@96:35 - no applicable action for [appender-ref], current ElementPath  is [[configuration][springProfile][logger][appender-ref]]
16:29:39,109 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@99:54 - no applicable action for [logger], current ElementPath  is [[configuration][springProfile][logger]]
16:29:39,109 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@100:35 - no applicable action for [appender-ref], current ElementPath  is [[configuration][springProfile][logger][appender-ref]]
16:29:39,109 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@103:23 - no applicable action for [root], current ElementPath  is [[configuration][springProfile][root]]
16:29:39,109 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@104:35 - no applicable action for [appender-ref], current ElementPath  is [[configuration][springProfile][root][appender-ref]]
16:29:39,109 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@109:28 - no applicable action for [springProfile], current ElementPath  is [[configuration][springProfile]]
16:29:39,110 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@110:72 - no applicable action for [appender], current ElementPath  is [[configuration][springProfile][appender]]
16:29:39,110 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@111:13 - no applicable action for [encoder], current ElementPath  is [[configuration][springProfile][appender][encoder]]
16:29:39,110 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@112:14 - no applicable action for [pattern], current ElementPath  is [[configuration][springProfile][appender][encoder][pattern]]
16:29:39,110 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@113:14 - no applicable action for [charset], current ElementPath  is [[configuration][springProfile][appender][encoder][charset]]
16:29:39,110 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@117:76 - no applicable action for [appender], current ElementPath  is [[configuration][springProfile][appender]]
16:29:39,110 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@118:13 - no applicable action for [encoder], current ElementPath  is [[configuration][springProfile][appender][encoder]]
16:29:39,110 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@119:14 - no applicable action for [pattern], current ElementPath  is [[configuration][springProfile][appender][encoder][pattern]]
16:29:39,110 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@120:14 - no applicable action for [charset], current ElementPath  is [[configuration][springProfile][appender][encoder][charset]]
16:29:39,110 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@124:54 - no applicable action for [logger], current ElementPath  is [[configuration][springProfile][logger]]
16:29:39,110 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@125:38 - no applicable action for [appender-ref], current ElementPath  is [[configuration][springProfile][logger][appender-ref]]
16:29:39,111 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@128:23 - no applicable action for [root], current ElementPath  is [[configuration][springProfile][root]]
16:29:39,111 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@129:34 - no applicable action for [appender-ref], current ElementPath  is [[configuration][springProfile][root][appender-ref]]

So as I already said if I remove scan=true the configuration works. If I remove springProfiles and properties and leave scan=true the configuration works again but with BOTH somethings is not right?

I assume the fact that it is most likely impossible to do so but did someone find a way of doing it?

EDIT: Close to a week after I posted my question Spring updated their documentation. Still I am looking for answer and I asume that there can be a way maybe using some middle layer of property file between Spring properties and logback configuration file because as the logback documentation says you can import property files into the configuration. But still even if so the problem with springProfile remains.

like image 233
Lazar Lazarov Avatar asked Jan 11 '17 14:01

Lazar Lazarov


People also ask

Does Spring Boot support Logback?

Spring Boot provides a number of logback configurations that be included from your own configuration. These includes are designed to allow certain common Spring Boot conventions to be re-applied. defaults. xml - Provides conversion rules, pattern properties and common logger configurations.

How do I enable Logback in Spring Boot?

To configure Logback for a Spring Boot project via XML, create the logback. xml or logback-spring. xml file under the src/main/resources folder. The configuration in XML file will override the logging properties in the application.

How do I change the Logback configuration file?

Setting the location of the configuration file via a system property. You may specify the location of the default configuration file with a system property named "logback. configurationFile" . The value of this property can be a URL, a resource on the class path or a path to a file external to the application.


1 Answers

The Spring springProfile and springProperty elements have issues with scan.

More information can be found at:

https://springframework.guru/using-logback-spring-boot/

The issue is logged at:

https://github.com/spring-projects/spring-boot/issues/7955

like image 195
user2693135 Avatar answered Oct 13 '22 01:10

user2693135