A keycloak module (including a kafka producer) is deployed to "keycloak-4.8.1.Final" server.
My Problem:
Even I used INFO
log level, DEBUG
messages are logging from Kafka library. So I want to stop messy Kafka debug logs form Keyclaok log file. Can someone PLEASE support me to overcome the issue.
I suspect there may be a conflict on logging mechanisms used in Keycloak (jboss-logging) & Kafka (slf4j) it self.
Sample Log:
10:10:40,642 INFO [stdout] (kafka-producer-network-thread | InternalUserProvisioningProducer) 47473973 [kafka-producer-network-thread | InternalUserProvisioningProducer] DEBUG org.apache.kafka.clients.NetworkClient - [Producer clientId=InternalUserProvisioningProducer] Sending metadata request (type=MetadataRequest, topics=) to node localhost:9092 (id: 0 rack: null)
10:10:40,644 INFO [stdout] (kafka-producer-network-thread | InternalUserProvisioningProducer) 47473975 [kafka-producer-network-thread | InternalUserProvisioningProducer] DEBUG org.apache.kafka.clients.Metadata - Updated cluster metadata version 28 to Cluster(id = 5N8ICZgiS-GewacYHMDtlg, nodes = [localhost:9092 (id: 0 rack: null)], partitions = [])
Kafka lib (in pom.xml
):
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka_2.12</artifactId>
<version>1.0.1</version>
</dependency>
Keycloak Module config (module.xml
):
<module xmlns="urn:jboss:module:1.5" name="com.my.core.internal-user-authenticator-module">
<properties>
<property name="jboss.api" value="private"/>
</properties>
<resources>
<resource-root path="internal-user-authenticator-module-0.0.1-SNAPSHOT.jar"/>
</resources>
<dependencies>
<module name="org.keycloak.keycloak-core"/>
<module name="org.keycloak.keycloak-common"/>
<module name="org.keycloak.keycloak-services"/>
<module name="org.keycloak.keycloak-server-spi"/>
<module name="org.keycloak.keycloak-server-spi-private"/>
<module name="javax.api"/>
<module name="javax.ws.rs.api"/>
<module name="javax.persistence.api"/>
<module name="org.jboss.resteasy.resteasy-jaxrs"/>
<module name="com.sun.xml.bind"/>
<module name="javax.xml.bind.api"/>
<module name="org.jboss.resteasy.resteasy-jaxb-provider"/>
<module name="org.wildfly.security.elytron"/>
<module name="org.bouncycastle"/>
<module name="com.fasterxml.jackson.core.jackson-core" export="true"/>
<module name="com.fasterxml.jackson.core.jackson-databind" export="true"/>
</dependencies>
keycloak logging config (in standalone.xml
):
<subsystem xmlns="urn:jboss:domain:logging:6.0">
<console-handler name="CONSOLE">
<level name="INFO"/>
<formatter>
<named-formatter name="COLOR-PATTERN"/>
</formatter>
</console-handler>
<periodic-rotating-file-handler name="FILE" autoflush="true">
<formatter>
<named-formatter name="PATTERN"/>
</formatter>
<file relative-to="jboss.server.log.dir" path="server.log"/>
<suffix value=".yyyy-MM-dd"/>
<append value="true"/>
</periodic-rotating-file-handler>
<logger category="com.arjuna">
<level name="WARN"/>
</logger>
<logger category="org.jboss.as.config">
<level name="DEBUG"/>
</logger>
<logger category="sun.rmi">
<level name="WARN"/>
</logger>
<root-logger>
<level name="INFO"/>
<handlers>
<handler name="CONSOLE"/>
<handler name="FILE"/>
</handlers>
</root-logger>
<formatter name="PATTERN">
<pattern-formatter pattern="%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%c] (%t) %s%e%n"/>
</formatter>
<formatter name="COLOR-PATTERN">
<pattern-formatter pattern="%K{level}%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%e%n"/>
</formatter>
</subsystem>
Thank you.
You need to also make sure that the log level on the producer side is set to INFO
as well. In log4j.properties
file you should have something similar to
log4j.rootLogger=INFO, stderr
log4j.appender.stderr=org.apache.log4j.ConsoleAppender
log4j.appender.stderr.layout=org.apache.log4j.PatternLayout
log4j.appender.stderr.layout.ConversionPattern=[%d] %p %m (%c)%n
log4j.appender.stderr.Target=System.err
And pass this file to your Kafka Producer:
-Dlog4j.configuration=file:/path/to/log4j.properties