Exception Logging ignored when using logstash-logback-encoder
Opened this issue · 3 comments
afavre commented
Hello,
I upgraded from the previous version of the project io.github.microutils
and noticed that I could not make work Exception logging work when using logstash-logback-encoder (version 7.0.4).
I tried with a small Micronaut Project with Kotlin adding these 2 dependencies:
implementation("io.github.oshai:kotlin-logging-jvm:7.0.0")
implementation("net.logstash.logback:logstash-logback-encoder:7.4")
Logback Config:
<configuration>
<appender name="JSON_CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="net.logstash.logback.encoder.LogstashEncoder" />
</appender>
<root level="INFO">
<appender-ref ref="JSON_CONSOLE" />
</root>
</configuration>
Controller
package example.micronaut
import io.github.oshai.kotlinlogging.KotlinLogging
import io.micronaut.http.annotation.Controller
import io.micronaut.http.annotation.Get
val log = KotlinLogging.logger {}
@Controller
open class HomeController() {
@Get
fun index(): Map<String, String> {
try {
throw Exception("Issue with my code")
} catch (e: Exception) {
log.error(e) { "Error with stacktrace" }
log.error { "Error without stacktrace" }
}
log.info { "Back to the main code" }
return mapOf("message" to "Hello World")
}
}
Output:
{"message":"Error without stacktrace","logger_name":"example.micronaut.HomeController","level":"ERROR"}
{"message":"Back to the main code","logger_name":"example.micronaut.HomeController","level":"INFO"}
It works fine is using the default ch.qos.logback.core.ConsoleAppender
.
Am I doing something wrong?
github-actions commented
Thank you for reporting an issue. See the wiki for documentation and slack for questions.
oshai commented
Doesn’t seems like the issue is related to that lib.
ssouza commented
+1