I have a springboot application. When I give the following command

$ java -Dspring.config.location=../src/main/resources/application-dev.properties -Dlogback.configurationFile=../src/main/resources/logback-spring.xml  -jar some-ingestion-1.0.0.jar

I get this error and the application fails to start:

Caused by: java.lang.IllegalStateException: java.lang.IllegalStateException: Logback configuration error detected:
ERROR in ch.qos.logback.core.joran.spi.Interpreter@28:84 - no applicable action for [springProperty], current ElementPath  is [[configuration][springProperty]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@31:112 - no applicable action for [springProperty], current ElementPath  is [[configuration][springProperty]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@34:71 - no applicable action for [springProperty], current ElementPath  is [[configuration][springProperty]]

Here is my logback-spring.xml:

....
<springProperty scope="context" name="logging.level.org.hibernate.SQL"
                source="logging.level.org.hibernate.SQL" defaultValue="warn" />

<springProperty scope="context" name="logging.level.org.hibernate.type.descriptor.sql.BasicBinder"
                source="logging.level.org.hibernate.type.descriptor.sql.BasicBinder" defaultValue="info" />

<springProperty scope="context" name="logging.level.com.abc.some.ingestion"
                source="com.abc.some.ingestion" level="info"/>
...

And here is my applications.property:

#Logging overrides
logging.level.org.hibernate.SQL=DEBUG
logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE
logging.level.com.abc.some.ingestion=TRACE

Irrespective of whether above are commented out, the application fails to start with the above error. But if I comment out the above 3 and set them as below in logback-spring.xml:

<logger name="com.abc.some.ingestion" level="info"/>
<logger name="org.hibernate.SQL" level="warn"/>
<logger name="org.hibernate.type.descriptor.sql.BasicBinder" level="info"/>

then application is able to start up. The idea is to be able to override settings in logback with the ones in application.properties.

The requirement requirement has eveolved overtime. logback configuration file is provided to java jar to be able to override application log history

0

There are 0 answers