Logstash-Logback Encoder: "IllegalAccessError: failed to access class [...]"

I try to send logs from a java application with the Logstash tcp socket appender to logstash. The java app. already works with logback 1.1.9 (slf4j) and other appenders.

Now I added the following lines to the logback-test.xml:

	<appender name="logstash" class="net.logstash.logback.appender.LogstashTcpSocketAppender">
        <encoder class="net.logstash.logback.encoder.LogstashEncoder">
        <keepAliveDuration>5 minutes</keepAliveDuration>

<level value="info"/>
<appender-ref ref="logstash" />

But when I add the appender and start my java application, I get an error from the JVM Launcher "A Java Exception has occured" and I get the following console text:

Exception in thread "main" java.lang.IllegalAccessError: failed to access class ch.qos.logback.core.status.OnPrintStreamStatusListenerBase from class net.logstash.logback.status.LevelFilteringStatusListener (ch.qos.logback.core.status.OnPrintStreamStatusListenerBase and net.logstash.logback.status.LevelFilteringStatusListener are in unnamed module of loader 'app')
	at net.logstash.logback.status.LevelFilteringStatusListener.setDelegate(LevelFilteringStatusListener.java:67)
	at net.logstash.logback.appender.AsyncDisruptorAppender.start(AsyncDisruptorAppender.java:370)
	at net.logstash.logback.appender.AbstractLogstashTcpSocketAppender.start(AbstractLogstashTcpSocketAppender.java:1009)
	at ch.qos.logback.core.joran.action.AppenderAction.end(AppenderAction.java:90)
	at ch.qos.logback.core.joran.spi.Interpreter.callEndAction(Interpreter.java:309)
	at ch.qos.logback.core.joran.spi.Interpreter.endElement(Interpreter.java:193)
	at ch.qos.logback.core.joran.spi.Interpreter.endElement(Interpreter.java:179)
	at ch.qos.logback.core.joran.spi.EventPlayer.play(EventPlayer.java:62)
	at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:158)
	at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:145)
	at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:103)
	at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:53)
	at ch.qos.logback.classic.util.ContextInitializer.configureByResource(ContextInitializer.java:75)
	at ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:150)
	at org.slf4j.impl.StaticLoggerBinder.init(StaticLoggerBinder.java:84)
	at org.slf4j.impl.StaticLoggerBinder.<clinit>(StaticLoggerBinder.java:55)
	at org.slf4j.LoggerFactory.bind(LoggerFactory.java:150)
	at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:124)
	at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:412)
	at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:357)
	at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:383)

I included the logstash 6.3 jar-file and because of this error, I also tried it with an older version, 4.9. I'm not using Spring-Boot.

I have no more idea what I can do.

I now found out that when I add the following line to my appender definition, my java application is running without the error:


But I don't get any log to Logstash. I already used Logstash with Filebeat and also Kibana and it work. But the TCPSocketAppender don't send logs to logstash.

Here my logstash.conf input:

input {
   tcp {
      mode => "server"
      port => 5010
      codec => json

Why I don't get the logs from the java application in Kibana/Logstash/Elasticseach?
Perhabs, there is a problem with the versions of the logstash-logback-encoder and logback. I tried 6.3, 4.9 and 4.8 from the encoder. But without the line <addDefaultStatusListener>false</addDefaultStatusListener> I get the error and with the line, I get no logs in Logstash.


I updated logback from version 1.1.9 to 1.2.3. When I deleted the old jar files and included the new jar files (jcl-over-slf4j 1.7.25, jul-to-slf4j 1.7.25, log4j-over-slf4j 1.7.25, slf4j-api 1.7.25, logback-classic 1.2.3, logback-core 1.2.3), I got 649 times the error "Logger cannot be resolved to a type". I fixed this by opening the properties from the logback project, going on "Order and Export" and setting a marker in every checkbox --> Apply and close.

Now my java application is working and don't throw any more the IllegalAccessError.

I also found out at the old logback version that I can add the line <addDefaultStatusListener>false</addDefaultStatusListener>

to the appender definition to fix the IllegalAccessError. More information here.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.