wildfly日志流到kafka

rsaldnfx  于 2021-06-04  发布在  Kafka
关注(0)|答案(0)|浏览(373)

我正在尝试配置wildfly18将log4j日志流式传输到kafka主题。我执行了以下配置:
模块\system\layers\base\org\apache\kafka\clients

<?xml version="1.0" encoding="UTF-8"?>
<module name="org.apache.kafka.clients" xmlns="urn:jboss:module:1.8">
<resources>
    <resource-root path="kafka-clients-2.6.0.jar"/>
    <resource-root path="snappy-java-1.1.7.3.jar"/>
    <resource-root path="lz4-java-1.7.1.jar"/>
</resources>
<dependencies>
    <module name="javax.api"/>
    <module name="org.slf4j"/>
</dependencies>

模块\system\layers\base\org\apache\kafka\log4jappender

<?xml version="1.0" encoding="UTF-8"?>
<module name="org.apache.kafka.log4jappender" xmlns="urn:jboss:module:1.8">
<resources>
    <resource-root path="kafka-log4j-appender-2.6.0.jar"/>
    <resource-root path="slf4j-log4j12-1.7.30.jar"/>
</resources>
<dependencies>
    <module name="org.slf4j"/>
    <module name="org.apache.kafka.clients" />
    <module name="org.jboss.log4j.logmanager" />
</dependencies>

模块\system\layers\base\org\apache\log4j

<?xml version="1.0" encoding="UTF-8"?>
<module name="org.apache.kafka.log4jappender" xmlns="urn:jboss:module:1.8">
<resources>
    <resource-root path="kafka-log4j-appender-2.6.0.jar"/>
    <resource-root path="slf4j-log4j12-1.7.30.jar"/>
</resources>
<dependencies>
    <module name="org.slf4j"/>
    <module name="org.apache.kafka.clients" />
    <module name="org.jboss.log4j.logmanager" />
</dependencies>

最后是modules\system\layers\base\org\jboss\as\standalone

<?xml version="1.0" encoding="UTF-8"?>
<module name="org.jboss.as.standalone" xmlns="urn:jboss:module:1.6">
 ...
<dependencies>
...
    <module name="org.jboss.logmanager" services="import"/>
    <module name="org.jboss.as.jmx" services="import"/>
    <module name="org.jboss.as.server" export="true"/>
    <module name="org.jboss.vfs" services="import"/>
    <module name="org.wildfly.security.elytron-private" services="import"/>
    <module name="org.apache.kafka.clients" />
</dependencies>

然后在日志子系统中配置了自定义处理程序和异步处理程序。不幸的是,这部分起作用。wildfly正在尝试使用新的记录器,但是kafka库找不到org.apache.kafka.common.serialization.bytearrayserializer类。

15:49:23,113 INFO  [org.wildfly.extension.messaging-activemq] (MSC service thread 1-1) 
WFLYMSGAMQ0001: AIO wasn't located on this platform, it will fall back to using pure Java NIO.
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.jboss.logmanager.config.AbstractPropertyConfiguration$6.applyPostCreate(AbstractPropertyConfiguration.java:476)
    at org.jboss.logmanager.config.AbstractPropertyConfiguration$6.applyPostCreate(AbstractPropertyConfiguration.java:460)
    at org.jboss.logmanager.config.LogContextConfigurationImpl.doApplyPostCreate(LogContextConfigurationImpl.java:313)
    at org.jboss.logmanager.config.LogContextConfigurationImpl.doPrepare(LogContextConfigurationImpl.java:345)
    at org.jboss.logmanager.config.LogContextConfigurationImpl.prepare(LogContextConfigurationImpl.java:291)
    at org.jboss.as.logging.logmanager.ConfigurationPersistence.prepare(ConfigurationPersistence.java:299)
    at org.jboss.as.logging.LoggingOperations$CommitOperationStepHandler.execute(LoggingOperations.java:107)
    at org.jboss.as.controller.AbstractOperationContext.executeStep(AbstractOperationContext.java:999)
    at org.jboss.as.controller.AbstractOperationContext.processStages(AbstractOperationContext.java:743)
    at org.jboss.as.controller.AbstractOperationContext.executeOperation(AbstractOperationContext.java:467)
    at org.jboss.as.controller.OperationContextImpl.executeOperation(OperationContextImpl.java:1413)
    at org.jboss.as.controller.ModelControllerImpl.boot(ModelControllerImpl.java:521)
    at org.jboss.as.controller.AbstractControllerService.boot(AbstractControllerService.java:472)
    at org.jboss.as.controller.AbstractControllerService.boot(AbstractControllerService.java:434)
    at org.jboss.as.server.ServerService.boot(ServerService.java:435)
    at org.jboss.as.server.ServerService.boot(ServerService.java:394)
    at org.jboss.as.controller.AbstractControllerService$1.run(AbstractControllerService.java:374)
    at java.lang.Thread.run(Thread.java:745)
   Caused by: org.apache.kafka.common.config.ConfigException: Invalid value org.apache.kafka.common.serialization.ByteArraySerializer for configuration key.serializer: Class org.apache.kafka.common.serialization.ByteArraySerializer could not be found.
    at org.apache.kafka.common.config.ConfigDef.parseType(ConfigDef.java:727)
    at org.apache.kafka.common.config.ConfigDef.parseValue(ConfigDef.java:473)
    at org.apache.kafka.common.config.ConfigDef.parse(ConfigDef.java:466)
    at org.apache.kafka.common.config.AbstractConfig.<init>(AbstractConfig.java:108)
    at org.apache.kafka.common.config.AbstractConfig.<init>(AbstractConfig.java:129)
    at org.apache.kafka.clients.producer.ProducerConfig.<init>(ProducerConfig.java:396)
    at org.apache.kafka.clients.producer.KafkaProducer.<init>(KafkaProducer.java:326)
    at org.apache.kafka.clients.producer.KafkaProducer.<init>(KafkaProducer.java:298)
    at org.apache.kafka.log4jappender.KafkaLog4jAppender.getKafkaProducer(KafkaLog4jAppender.java:319)
    at org.apache.kafka.log4jappender.KafkaLog4jAppender.activateOptions(KafkaLog4jAppender.java:313)
    at org.jboss.as.logging.logmanager.Log4jAppenderHandler.activate(Log4jAppenderHandler.java:102)
    ... 22 more

如果我将org.apache.kafka.clients设置为org.jboss.as.standalone中的依赖项没有错的话,应该可以解决这个问题,但它不起作用。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题