Search code examples
javaloggingjbossclientkeycloak

Keycloak-admin-client - turn off logging


While using keycloak-admin-client v.3.4.3 final with Java I am having difficulty with disabling default DEBUG logging when a new keycloak instance connection is set.

Basically in application output I get log output for :

DEBUG org.apache.http.headers DEBUG org.jboss.resteasy.plugins.providers

I would appreciate any suggestions. Since this is an external library I am not quite sure how can I use log4j.properties to disable it.


Solution

  • As an alternative, you can add logback.xml to your resources directory if you are using maven.
    The example below sets root logging to error and also give examples of setting specific packages to different levels.
    You can use this to tailor it to your needs.

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
        <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
            <!-- encoders are assigned the type ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
            <encoder>
                <pattern>[%d{HH:mm:ss.SSS}] %-5level - %msg%n</pattern>
            </encoder>
        </appender>
    
        <logger name="some.custom.path" level="debug" />
        <logger name="org.springframework" level="error" />
    
        <root level="error">
            <appender-ref ref="STDOUT" />
        </root>
    </configuration>