0

Kotlin-logging is a thin convenience wrapper around SLF4J. Its docs indicate I can choose an arbitrary logger name. But when I do, the logger stops working :-(

Here are the log declaration and log format that do work.

logback.xml file: <pattern>%d{HH:mm} %-5level %logger - %msg%n</pattern>

Kotlin file: val log = KotlinLogging.logger {}

Here are ways I specified logger name, which made logging in the class file stop working.

val log = KotlinLogging.logger("FOO")
val log = KotlinLogging.logger("FOO")
val log = LoggerFactory.getLogger("FOO")
val log = LoggerFactory.getLogger("FOO").toKLogger()

NOTES:

  • There are no messages to stderr indicating a log format or log setup errors.
  • Other logging in the app continues to work fine.
  • I only do console logging.
  • This is only for a personal project.

Question: Does kotlin-logging allow specifying an arbitrary logger name? If yes, how?

Thanks for your help.

devdanke
  • 1,309
  • 15
  • 27
  • Could this be a configuration issue? I.e. could the logger be working fine but just configured not to show output for the new name like it does for the original one? One way to check would be to display (in a way you _will_ see, e.g. with `println()`) the value of `log.isErrorEnabled()` (or whichever level you're expecting to see). – gidds Sep 09 '22 at 19:19
  • Thanks for the suggestion. I don't have any kind of filtering config. My simple config was copied from a Baeldung tutorial. I tried different log names. None worked. FOO is just an example. I treid your suggestion. The `println()` shows logging **is** enabled. – devdanke Sep 10 '22 at 08:35

0 Answers0