Search code examples
springspring-bootlogback

logback configuration error parse integer


I get the following error with the logback-spring.xml. %C is for class, not sure about {1.} after it.

Logging system failed to initialize using configuration from 'null'
java.lang.IllegalStateException: Logback configuration error detected: 
ERROR in ch.qos.logback.classic.pattern.ClassOfCallerConverter@436e641b - failed to parse integer string [1.] java.lang.NumberFormatException: For input string: "1."

Config file:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>

    <property name="LOGS" value="./logs" />

    <appender name="Console"
        class="ch.qos.logback.core.ConsoleAppender">
        <layout class="ch.qos.logback.classic.PatternLayout">
            <Pattern>
                %black(%d{ISO8601}) %highlight(%-5level) [%blue(%t)] %yellow(%C{1.}): %msg%n%throwable
            </Pattern>
        </layout>
    </appender>    
    
    <!-- LOG everything at INFO level -->
    <root level="info">        
        <appender-ref ref="Console" />
    </root>
   
</configuration>

Solution

  • According to the official documentation the conversion C takes an integer as an option. So just remove the dot . after the number %C{1.} and it will work fine.