Logging in full JSON format


I’m using the built-in JSON formatter for the log and I’d like to have the content of the “message” field to also be in JSON when appropriate (that is when I pass a JSONObject to the log method) .
Currently , the default JSON formatter stringifies the JSON in the output.

{“app_datetime”:“2021-02-04T12:55:43.356Z”,“sequence”:180,“loggerClassName”:“org.jboss.logging.Logger”,“loggerName”:“org.keycloak.events”,“severity_label”:“WARN”,“app_message”:{“type”:“LOGIN_ERROR”, …}

Is there a way to get the following expected output :
{“app_datetime”:“2021-02-04T12:55:43.356Z”,“sequence”:180,“loggerClassName”:“org.jboss.logging.Logger”,“loggerName”:“org.keycloak.events”,“severity_label”:“WARN”,“app_message”:{“type”:“LOGIN_ERROR”, … }


Hi, I also meet the same issue. Did you find a resolution at last?

This is not possible with the default logging event listener, as it is concatenating the message to a string. The actual message is the value to the key message.

If you also want to have the message details printed as JSON output, you‘ll have to implement a custom event listener, doing exactly this.