79522978

Date: 2025-03-20 12:50:28
Score: 1
Natty:
Report link

I have found the problem. As I don't define loggers by classes or packages, I had to put them in the global (<root>) since in each <appender> I have the filtering of the level I want.

So, the change to make is to delete all the <logger> and add the <appender-ref> inside <root>, defining a minimun level for the <root>:

    ...............
    <root level="debug">
        <appender-ref ref="STDOUT"/>
        <appender-ref ref="DEBUG_FILE"/>
        <appender-ref ref="INFO_FILE"/>
        <appender-ref ref="WARN_FILE"/>
        <appender-ref ref="ERROR_FILE"/>
    </root>
</configuration>

And now each log level goes into its own file.

To test it, in the code I have:

import io.github.oshai.kotlinlogging.KotlinLogging

private val logger = KotlinLogging.logger {}

fun main() = application {
    logger.debug { "Debug message" }
    logger.info { "Info message" }
    logger.warn { "Warn message" }
    logger.error { "Error message" } 
}
Reasons:
  • RegEx Blacklisted phrase (1): I want
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: MinionAttack