How to separate out file log handler for Keycloak events in separate log file ??

1,049 views
Skip to first unread message

SadaShiv Dash

unread,
Oct 12, 2022, 6:37:06 AM10/12/22
to Keycloak User
Hi All,

I am using keycloak 18.0.2,.
Currently I want to separate out the keycloak events in separate log file called "keycloakEvents.log".

When I was trying out the properties in the quarkus.properties file, it didn't work for me.
quarkus.log.file.enable=true
# Set path to the log file.
quarkus.log.file.path=${kc.home.dir:default}data/log/keycloakEvents.log

# Configure a file log handler.
quarkus.log.handler.file."STRUCTURED_LOGGING_FILE".enable=true
quarkus.log.handler.file."STRUCTURED_LOGGING_FILE".format=%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%c] (%t) %s%e%n

# Configure the category and associate it with the two named handlers.
quarkus.log.category."org.keycloak.events".level=INFO
quarkus.log.category."org.keycloak.events".handlers=STRUCTURED_LOGGING_FILE

Can someone  help me with this ? 

Best Regards
Sada Shiv Dash

Michał K

unread,
Oct 13, 2022, 9:04:31 AM10/13/22
to Keycloak User
Hi,

quarkus.log.file.path is configuration for root logger (so your default log file).

You should try like this:
quarkus.log.file.path=${kc.home.dir:default}data/log/defaultLogFile.log

And for keycloak events:
quarkus.log.handler.file."STRUCTURED_LOGGING_FILE".enable=true
quarkus.log.handler.file."STRUCTURED_LOGGING_FILE".format=%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%c] (%t) %s%e%n
quarkus.log.handler.file."STRUCTURED_LOGGING_FILE".path=${kc.home.dir:default}data/log/keycloakEvents.log
quarkus.log.handler.file."STRUCTURED_LOGGING_FILE".use-parent-handlers=false # this cause log will not be attached to default log file (if you want)
quarkus.log.category."org.keycloak.events".level=DEBUG # I'm not sure if for e.g. successful login proper level is DEBUG or INFO ;)
quarkus.log.category."org.keycloak.events".handlers=STRUCTURED_LOGGING_FILE

Best Regads,
Michal

Sada Shiv Dash

unread,
Oct 13, 2022, 11:24:41 AM10/13/22
to Michał K, Keycloak User
Hello Michal , 

Thank, Yes I was missing log.handler path.
I have corrected and it working fine.

Regards
Sada Shiv Dash

On 13-Oct-2022, at 6:34 PM, Michał K <misie...@gmail.com> wrote:

Hi,
--
You received this message because you are subscribed to the Google Groups "Keycloak User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to keycloak-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/keycloak-user/acef4946-dd57-4cb7-b8e2-eb1d0cb60c09n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages