How to get human-readable stack traces in JSON ECS logs #43038
-
Hi. We are running Keycloak with I would really prefer exception being just a standard String representation of it. Is there any way of configuring the normal exception reporting? (But we still have to log as JSON and it must be ECS compliant). Or is there a way of "replacing" logging framework and sending everything to, say, logback? Which we know we can configure the way we want. Many thanks PS: this is what I mean by "exception": {
"refId": 1,
"exceptionType": "com.fasterxml.jackson.databind.exc.MismatchedInputException",
"error.message": "No content to map due to end-of-input\n at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 1]",
"frames": [
{
"class": "com.fasterxml.jackson.databind.exc.MismatchedInputException",
"method": "from",
"line": 59
},
{
"class": "com.fasterxml.jackson.databind.ObjectMapper",
"method": "_initForReading",
"line": 5008
},
... |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
You can use multiple outputs for your purposes. You can use a log format for files that will be redirected to ECS, and a different format for the console logs - see the logging configuration docs https://www.keycloak.org/server/logging#_use_different_json_format_for_log_handlers. |
Beta Was this translation helpful? Give feedback.
-
ECS defines specific fields for errors: error.message – short error message error.type – type of the exception error.stack_trace – the stack trace Example ECS-compliant JSON snippet:
Notice that the stack trace is included as a string with \n for line breaks. This preserves human readability when viewed in Kibana or other ECS-compatible tools that render error.stack_trace. |
Beta Was this translation helpful? Give feedback.
-
Same problem encountered. See Quarkus documentation in In our case, the information now appears in key error.stack_trace with clasicc format (all lines info in value key) |
Beta Was this translation helpful? Give feedback.
Same problem encountered.
Solution: Add start variable in Keycloak.
- QUARKUS_LOG_CONSOLE_JSON_EXCEPTION_OUTPUT_TYPE=formatted
See Quarkus documentation in
quarkus.log.console.json.exception-output-type
In our case, the information now appears in key error.stack_trace with clasicc format (all lines info in value key)