使用slf4j.marker时,我正在获取java.lang.incompatibleclasschangeerror。似乎我在ClassPath中有几个SLF4J版本。但是,当执行Maven依赖性时:树说只有SLF4J 1.7.25。你们有什么想法可能是什么问题?依赖项如下:
- logback 1.2.3
- SLF4J 1.7.25
- logstash-logback-regoder 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)
您是正确的,因为ClassPath中的几个SLF4J版本
现在我们需要找出它是如何发生的
案例1:
当我查看logback 1.2.3
的Maven Reportor时,我发现它已经对SLF4J具有依赖性。
因此,当您加载logback 1.2.3时,SLF4J将自动添加
因此,如果您这样做,则无需将其他SLF4J添加到POM中。
请参考链接以获取更多详细信息 - 编译下降:
案例2:
查看wildfly/modules/system/layers/base/org/slf4j
文件夹查看是否已经添加了任何SLF4J罐子。如果是这样,您只需要编译
时SLF4J添加<scope>compile</scope>