一个keycloak模块(包括一个kafka生产者)被部署到“keycloak-4.8.1.Final”服务器。
我的问题:
甚至我也用过信息日志级别,调试消息是从 Kafka 库记录的。因此,我想停止 Keyclaok 日志文件中混乱的 Kafka 调试日志。有人可以帮我解决这个问题吗?
我怀疑 Keycloak 中使用的日志记录机制可能存在冲突(jboss 日志)和卡夫卡(slf4j) 本身。
样本日志:
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 库(pom.xml):
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka_2.12</artifactId>
<version>1.0.1</version>
</dependency>
Keycloak 模块配置(模块.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 日志配置(在独立文件):
<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>
谢谢....
答案1
一旦将 log4j.properties 文件添加到 Keycloak 部署中,它就会起作用。
log4j.属性:
log4j.rootLogger=信息
standalone.sh 或 standalone.conf:
-Dlog4j.configuration=文件:“$JBOSS_CONFIG_DIR”/log4j.properties