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" }
}