Vague "text_context" in json logs when use LogFormat.colored
RicoGit opened this issue · 5 comments
Take logger format from docs: https://zio.github.io/zio-logging/docs/overview/overview_index#json-console-log
private val logger =
Runtime.removeDefaultLoggers >>> consoleJson(
LogFormat.default + LogFormat.annotation(LogAnnotation.TraceId) + LogFormat.annotation(
userLogAnnotation
)
)
Get pretty log message:
{"timestamp":"2022-08-30T14:47:56.974589+04:00","level":"INFO","thread":"zio-fiber-6","message":"Start application"}
change LogFormat.default
to LogFormat.colored
Get additional field "text_context"
{"text_content":"\u001b[34m\u001b[0m \u001b[36m\u001b[0m \u001b[37m\u001b[0m \u001b[36m\u001b[0m","timestamp":"2022-08-30T14:49:50.545197+04:00","level":"INFO","thread":"zio-fiber-6","message":"Start application"}
Is it expected behavior?
Hi @RicoGit, thank you for report
not sure if this is expected behavior, in general I think that json LogAppender adding everything under text_content attribute, in case when specific "sub" LogFormat do not have defined attribute
LogFormat.colored using ansi escape codes to change colors in terminal
but in current implementation, it does not look like that this combination of json console appender together wit format which using ansi escape codes working properly
i will discuss it, and let you know (i am not author of this LogAppender)
thank you
We could of course drop all ansi escape codes in text_content when we create the json.
I cannot see that we can support colored json as it wouldn't be json anymore, right?
Yep, looks good in 2.1.1, thank you guys!