Hands-on practice

Report a typo

Look at this code snippet and the relevant logback.xml file and answer what will the logger output to the console.

import org.slf4j.LoggerFactory

class Example {
    private val LOG = LoggerFactory.getLogger(Example::class.java)

    fun log() {
        LOG.debug("Don't worry, I'm logging.")
    }
}

fun main() {
    Example().log()
}
<configuration>
    <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <pattern>%msg%n</pattern>
        </encoder>
    </appender>

    <root level="debug">
        <appender-ref ref="console" />
    </root>
</configuration>

Pay attention both to the logger level and the encoder pattern.

Enter a short text
___

Create a free account to access the full topic