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

**URL:** <https://discuss.elastic.co/t/logstash-logback-encoder-illegalaccesserror-failed-to-access-class/219216>\
**Category:** Logstash\
**Created:** [February 13, 2020, 1:50pm UTC](https://discuss.elastic.co/t/logstash-logback-encoder-illegalaccesserror-failed-to-access-class/219216 "2020-02-13T13:50:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ruhrpottler](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ruhrpottler/32/68733_2.png) [@Ruhrpottler](https://discuss.elastic.co/u/Ruhrpottler)\
**Post date:** [February 13, 2020, 1:50pm UTC](https://discuss.elastic.co/t/logstash-logback-encoder-illegalaccesserror-failed-to-access-class/219216/1 "2020-02-13T13:50:16Z")

</div>

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:

```
<configuration>
	<appender name="logstash" class="net.logstash.logback.appender.LogstashTcpSocketAppender">
        <destination>[IP]:5010</destination>
        <encoder class="net.logstash.logback.encoder.LogstashEncoder">
            <fieldNames>
                <message>log_msg</message>
            </fieldNames>
        </encoder>
        <keepAliveDuration>5 minutes</keepAliveDuration>
    </appender>

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

```

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.

---

<div class="post-metadata">

**Author:** ![Ruhrpottler](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ruhrpottler/32/68733_2.png) [@Ruhrpottler](https://discuss.elastic.co/u/Ruhrpottler)\
**Post date:** [February 17, 2020, 4:53pm UTC](https://discuss.elastic.co/t/logstash-logback-encoder-illegalaccesserror-failed-to-access-class/219216/2 "2020-02-17T16:53:50Z")

</div>

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

`<addDefaultStatusListener>false</addDefaultStatusListener>`

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.

---

<div class="post-metadata">

**Author:** ![Ruhrpottler](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ruhrpottler/32/68733_2.png) [@Ruhrpottler](https://discuss.elastic.co/u/Ruhrpottler)\
**Post date:** [February 21, 2020, 4:17pm UTC](https://discuss.elastic.co/t/logstash-logback-encoder-illegalaccesserror-failed-to-access-class/219216/3 "2020-02-21T16:17:52Z")

</div>

**Solution:**

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](https://mvnrepository.com/artifact/ch.qos.logback/logback-classic/1.2.3) (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](https://github.com/logstash/logstash-logback-encoder/blob/2e98d6c74d3e19bfd6780dfe593e8b020ed7d10e/README.md#status-listeners).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [March 20, 2020, 4:18pm UTC](https://discuss.elastic.co/t/logstash-logback-encoder-illegalaccesserror-failed-to-access-class/219216/4 "2020-03-20T16:18:00Z")

</div>

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