Laurenzo
Laurenzo

Reputation: 575

How to customise how Keycloak logs stack traces

Problem: Keycloak logs stack traces in exceptions to multiple lines and I'd rather have the stack trace customised (ie. separate by some arbitrary character, say |). The logs are sent to Splunk for later perusal and I'd rather have the whole exception logged (with the full stack trace) as one line / event there as well.

Example of log generated by Keycloak:

2023-08-22 07:19:22,081 ERROR [com.example.BaseUserProvider] (executor-thread-0) Error getting user: org.apache.http.conn.HttpHostConnectException: Connect to host.docker.internal:8080 [host.docker.internal/192.168.65.254] failed: Connection refused (Connection refused)
    at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:156)
    at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:376)
    at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:393)
    at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)
    at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:186)
    at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)

I am a bit lost as how to customise the stack trace. Per Keycloak documentation, log format can be customised but that doesn't have an option to customise the exception format, see Keycloak documentation: https://www.keycloak.org/server/logging mentions this:

Keycloak uses the JBoss Logging framework. The following is a high-level overview for the available log handlers:

  • root

    • console (default)

I am using Keycloak 20.0.5 (official Docker image) as base.

Upvotes: 1

Views: 903

Answers (0)

Related Questions