gpt4 book ai didi

java - 使用标记的logstash-logback-encoder错误

转载 作者:行者123 更新时间:2023-12-02 11:26:33 26 4
gpt4 key购买 nike

使用 slf4j.Marker 时出现 java.lang.InknownClassChangeError 错误。看来我在类路径中有几个 slf4j 版本。但是当执行maven dependency:tree时它说只有slf4j 1.7.25。你们有什么想法可能是什么问题吗?依赖关系如下:

  • logback 1.2.3
  • slf4j 1.7.25
  • logstash-logback-编码器5.0

该应用程序部署在WildFlly 8.2.1 AS上。

> -ERROR in net.logstash.logback.appender.LogstashTcpSocketAppender[stash] - Unable to process event: Class net.logstash.logback.marker.ObjectAppendingMarker does not implement the requested interface org.slf4j.Marker java.lang.IncompatibleClassChangeError: Class net.logstash.logback.marker.ObjectAppendingMarker does not implement the requested interface org.slf4j.Marker
>
> 2018-03-31 00:17:03,287 INFO [stdout] (logback-appender-stash-127.0.0.1:4560-2) at java.lang.IncompatibleClassChangeError: Class net.logstash.logback.marker.ObjectAppendingMarker does not implement the requested interface org.slf4j.Marker
>
> 2018-03-31 00:17:03,287 INFO [stdout] (logback-appender-stash-127.0.0.1:4560-2) at at net.logstash.logback.composite.loggingevent.JsonMessageJsonProvider.writeTo(JsonMessageJsonProvider.java:52)
>
> 2018-03-31 00:17:03,287 INFO [stdout] (logback-appender-stash-127.0.0.1:4560-2) at at net.logstash.logback.composite.loggingevent.JsonMessageJsonProvider.writeTo(JsonMessageJsonProvider.java:31)
>
> 2018-03-31 00:17:03,287 INFO [stdout] (logback-appender-stash-127.0.0.1:4560-2) at at net.logstash.logback.composite.JsonProviders.writeTo(JsonProviders.java:77)
>
> 2018-03-31 00:17:03,287 INFO [stdout] (logback-appender-stash-127.0.0.1:4560-2) at at net.logstash.logback.composite.CompositeJsonFormatter.writeEventToGenerator(CompositeJsonFormatter.java:175)
>
> 2018-03-31 00:17:03,288 INFO [stdout] (logback-appender-stash-127.0.0.1:4560-2) at at net.logstash.logback.composite.CompositeJsonFormatter.writeEventToOutputStream(CompositeJsonFormatter.java:152)
>
> 2018-03-31 00:17:03,288 INFO [stdout] (logback-appender-stash-127.0.0.1:4560-2) at at net.logstash.logback.encoder.CompositeJsonEncoder.encode(CompositeJsonEncoder.java:114)
>
> 2018-03-31 00:17:03,288 INFO [stdout] (logback-appender-stash-127.0.0.1:4560-2) at at net.logstash.logback.encoder.CompositeJsonEncoder.encode(CompositeJsonEncoder.java:32)
>
> 2018-03-31 00:17:03,288 INFO [stdout] (logback-appender-stash-127.0.0.1:4560-2) at at net.logstash.logback.appender.AbstractLogstashTcpSocketAppender$TcpSendingEventHandler.onEvent(AbstractLogstashTcpSocketAppender.java:454)
>
> 2018-03-31 00:17:03,288 INFO [stdout] (logback-appender-stash-127.0.0.1:4560-2) at at net.logstash.logback.appender.AbstractLogstashTcpSocketAppender$TcpSendingEventHandler.onEvent(AbstractLogstashTcpSocketAppender.java:264)
>
> 2018-03-31 00:17:03,288 INFO [stdout] (logback-appender-stash-127.0.0.1:4560-2) at at net.logstash.logback.appender.AsyncDisruptorAppender$EventClearingEventHandler.onEvent(AsyncDisruptorAppender.java:330)
>
> 2018-03-31 00:17:03,288 INFO [stdout] (logback-appender-stash-127.0.0.1:4560-2) at at net.logstash.logback.appender.AsyncDisruptorAppender$EventClearingEventHandler.onEvent(AsyncDisruptorAppender.java:318)
>
> 2018-03-31 00:17:03,288 INFO [stdout] (logback-appender-stash-127.0.0.1:4560-2)

最佳答案

嗯,你是对的,出现这个问题是因为类路径中有多个 slf4j 版本

现在我们需要找出它是如何发生的

案例1:

当我查看 Maven 存储库时 logback 1.2.3我看到它已经依赖于 slf4j。

所以当你加载logback 1.2.3时,会自动添加slf4j

所以你不需要在pom中添加额外的slf4j,如果你这样做,请删除它。

引用link有关更多详细信息 - 编译依赖项:

情况2:

查看wildfly/modules/system/layers/base/org/slf4j

文件夹查看是否已添加任何 slf4j jar。如果是这样,则仅在编译时需要 slf4j

添加<scope>compile</scope>

关于java - 使用标记的logstash-logback-encoder错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49586498/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com