is there a way to test the output of `KotlinLoggin...
# kotest
a
is there a way to test the output of
KotlinLogging
? The following captures nothing
Copy code
class OutputTest: StringSpec() {
    private val logger = KotlinLogging.logger {}
    init {
        "capture" {
            captureStandardOut {
                logger.error("oops")
            } shouldBe "oops\n"
        }
        "logger" {
            captureStandardErr {
                logger.error("oops")
            } shouldBe "oops\n"
        }
    }
}

io.kotest.assertions.AssertionFailedError: expected:<"oops
"> but was:<<empty string>>
k
I thing it doesn't capture anything because the log is sent to whatever logging backend you're using (such as logback) and not necessarily to stdout or stderr. I don't know if Kotest has any feature for capturing logs, but I've used logcapture in the past and found it useful.
gratitude thank you 1