0
votes

I'm migrating a legacy app to Spring Boot and I've faced with the following problem: when I start the app it fails because of the following exception:

Exception in thread "main" java.lang.IllegalStateException: Logback configuration error detected: ERROR in ch.qos.logback.core.joran.spi.Interpreter@10:21 - no applicable action for [BufferedIO], current ElementPath is [[configuration][appender][BufferedIO]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@11:25 - no applicable action for [ImmediateFlush], current ElementPath is [[configuration][appender][ImmediateFlush]]
at org.springframework.boot.logging.logback.LogbackLoggingSystem.loadConfiguration(LogbackLoggingSystem.java:161) at org.springframework.boot.logging.logback.LogbackLoggingSystem.reinitialize(LogbackLoggingSystem.java:207) at org.springframework.boot.logging.AbstractLoggingSystem.initializeWithConventions(AbstractLoggingSystem.java:65) at org.springframework.boot.logging.AbstractLoggingSystem.initialize(AbstractLoggingSystem.java:50) at org.springframework.boot.logging.logback.LogbackLoggingSystem.initialize(LogbackLoggingSystem.java:114) at org.springframework.boot.logging.LoggingApplicationListener.initializeSystem(LoggingApplicationListener.java:299) at org.springframework.boot.logging.LoggingApplicationListener.initialize(LoggingApplicationListener.java:272) at org.springframework.boot.logging.LoggingApplicationListener.onApplicationEnvironmentPreparedEvent(LoggingApplicationListener.java:235) at org.springframework.boot.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:208) at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:167) at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:122) at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:72) at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54) at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:338) at org.springframework.boot.SpringApplication.run(SpringApplication.java:309) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1187) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1176) at com.some_company.SomeApp.main(SomeApp.java:28)

So Logback can't resolve BuferredIO and ImmediateFlush properties. I've tried to see their docs but it seems to be out-of-date as it says such properties exist + I've found e.g. for OutputStreamAppender that it doesn't have the immediateFlush property while according to the docs it should.

I can't find any info on if Logback still supports the following properties now. Could you please help and suggest some ideas on how I can achieve the same result as with the properties previously? Maybe they are somewhere else:)

Thank you very much!:)

UPDATE: Adding a Logback configuration snapshot:

    <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <File>${logdir}/some-app.log</File>
        <Append>true</Append>        
        <BufferedIO>false</BufferedIO>
        <ImmediateFlush>true</ImmediateFlush>
        <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
            <FileNamePattern>${logdir}/archive-some-app.%i.log.zip</FileNamePattern>
            <MinIndex>1</MinIndex>
            <MaxIndex>10</MaxIndex>
        </rollingPolicy>

        <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
            <MaxFileSize>20MB</MaxFileSize>
        </triggeringPolicy>

        <encoder class="net.logstash.logback.encoder.LogstashEncoder">
            <fieldNames>
                <timestamp>timestamp</timestamp>
            </fieldNames>
        </encoder>
    </appender>

Logback version is 1.1.7 (was previously before the migration)

1
Showing your logback.xml would help.Ondřej Xicht Světlík
In addition to posting your logback.xml, could you also state what version of Logback you are using?glytching
@Ondřej Xicht Světlík How could I forget, thanks, added:)Dmitry Senkovich
@glytching sure, thanks for the note, please, the the updated questionDmitry Senkovich
Apparently, in 1.1.7 none of these two options is present. I found immediateFlush in 1.2.3 and bufferedIO in 0.9.7 or something like this. I have no idea on which version the documentation is based, but the date of last update (in 2008 which corresponds with the 0.9.x version) gives us a clue. 1.1.7 is from 2016 and 1.2.3 is from 2017.Ondřej Xicht Světlík

1 Answers

2
votes

Although ImmediateFlush is a valid configuration property for OutputStreamAppender (which RollingFileAppender extends) in the latest version of Logback (and hence is referenced in the latest docs) this was only added to OutputStreamAppender here in Feb 2017. So, immediateFlush is not a valid property of OutputStreamAppender (and hence is inaccessible from RollingFileAppender) in v1.1.7

This explains the following error:

no applicable action for [ImmediateFlush], current ElementPath is [[configuration][appender][ImmediateFlush]]

BufferedIO is an old configuration property which is no longer supported by Logback.

This explains the following error:

no applicable action for [BufferedIO], current ElementPath is [[configuration][appender][BufferedIO]]

In summary, you might consider upgrading to the latest Logback and just remove <BufferedIO>false</BufferedIO>. Or, continue to use v1.1.7 and remove both of these: <BufferedIO>false</BufferedIO> and <ImmediateFlush>true</ImmediateFlush>.