Setting log level in Keycloak docker container

I want to change the log level in a Docker container to see if it can shed any light on an issue I am seeing. This does not appear to be obviously documented in the Keycloak documentation, but Google suggests environment variable KEYCLOAK_LOGLEVEL. I have also tried KC_LOGLEVEL.
The environment variable in this docker compose snippet does not appear to make any difference to the log output. Is it incorrect?

     keycloak:
            image: quay.io/keycloak/keycloak:23.0.1
            command: start-dev
            container_name: keycloak
            networks:
                    - ztg_net
            ports:
                    - 8080:8080
            environment:
                    - KEYCLOAK_ADMIN=admin
                    - KEYCLOAK_ADMIN_PASSWORD=****
                    - KEYCLOAK_LOGLEVEL=DEBUG

The docs are pretty clear about that: Configuring logging - Keycloak
e.g. KC_LOG_LEVEL=DEBUG

2 Likes

That page doesn’t mention KC_LOGLEVEL, or any environment variables, that I can see? KC_LOGLEVEL had no obvious effect when I tried it, but I will try again.
I kind of expected the environment variables to be documented in the container documentation, but I couldn’t see a log level variable there either.

1 Like

My little friend, you are missing the _ between the words LOG and LEVEL. This is why Dasniko was mentioning KC_LOG_LEVEL and not KC_LOGLEVEL

2 Likes

All config options (and their corresponding environment variables) are documented here: All configuration - Keycloak

And - as nico pointed out - it is KC_LOG_LEVEL.

1 Like

Thanks, guys! :beers:
@embesozzi @ThoreKr

@tsr2:
If you expand the various log config options, you will find the exact spelling of the environment variables. For how Keycloak can be configured, see Configuring Keycloak - Keycloak
As Keycloak can be configured independently from how it is deployed/operated, you won’t find a deployment-specific config document. No matter how Keycloak is deployed, one can use all options to configure Keycloak.
Don’t ask Google, RTFM!

2 Likes

RTFM is good advice, but it’s not always easy to find the right page, I looked at the pages I expected to document it and didn’t find it in those pages. Obviously I didn’t find that page with the full list of options.
Thank you

This one worked for me.
(On Docker Desktop, macOs Sonoma m2 Pro)

version: "3.8"

services:
  keycloak:
    image: quay.io/keycloak/keycloak:25.0.2
    container_name: keycloack
    command: start-dev

    ports:
      - "6001:8080"
      - "4200:4200"
     
    environment:
      KEYCLOAK_ADMIN: admin
      KEYCLOAK_ADMIN_PASSWORD: admin
      KC_LOG_LEVEL: TRACE

1 Like

Hi,
I came across this post, double clicked “KC_LOG_LEVEL” and copied, followed the link yet I was unable to find KC_LOG_LEVEL. Do the docs need updating?