Trying to get keycloak log to file

Hello
I would like to get the log from keycloak in a log file.
If I try the start command :

bin/kc.[sh|bat] start --log=console,file --log-file=/<your-file.log>

from this documentation :

I get an error with --log-file option not allowed

If I try the following start command in a console :

sudo -u keycloak /opt/keycloak/bin/kc.sh start --spi-events-listener-jboss-logging-success-level=info --spi-events-listener-jboss-logging-error-level=error

from this documentation :
https://www.keycloak.org/docs/latest/server_admin/index.html#event-listener

it is better as I can have the log in the console.
B

But is there a way to forward this console flow to a file ?

Many thanks

Hello,

I know it’s an old issue, but since i face the same one recently, for anyone having the same issue i resolve it using :

bin/kc.sh start --log="console,file"  --log-level=INFO --log-file=/opt/keycloak/data/keycloak.log

Allowing you to write INFO log in both file and the console, in a file that you define

or in docker/podman just add :
-e KC_LOG=file,console -e KC_LOG_LEVEL=INFO -e KC_LOG_FILE=/opt/keycloak/data/keycloak.log

1 Like

Wondeful I had give up with the log file.
I just do it and it works
know I have to remove the warning I can see :wink:
Thanks