# Slf4j error not captured

**URL:** <https://discuss.elastic.co/t/slf4j-error-not-captured/216987>\
**Category:** APM\
**Tags:** java\
**Created:** [January 29, 2020, 11:09am UTC](https://discuss.elastic.co/t/slf4j-error-not-captured/216987 "2020-01-29T11:09:04Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![nugusbayevkk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nugusbayevkk/32/126683_2.png) [@nugusbayevkk](https://discuss.elastic.co/u/nugusbayevkk)\
**Post date:** [January 29, 2020, 11:09am UTC](https://discuss.elastic.co/t/slf4j-error-not-captured/216987/1 "2020-01-29T11:09:04Z")

</div>

If you are asking about a problem you are experiencing, please use the following template, as it will help us help you. If you have a different problem, please delete all of this text 🙂

**Kibana version** : 7.5.1

**Elasticsearch version** : 7.5.1

**APM Server version** : 7.5.1

**APM Agent language and version** : java, 1.12.1

**Browser version** : chromium Version 79.0.3945.130 (Official Build) snap (64-bit)

**Original install method (e.g. download page, yum, deb, from source, etc.) and version**: source, 1.12.1

**Fresh install or upgraded from other version?**

**Is there anything special in your setup?** For example, are you using the Logstash or Kafka outputs? Are you using a load balancer in front of the APM Servers? Have you changed index pattern, generated custom templates, changed agent configuration etc.

**Description of the problem including expected versus actual behavior. Please include screenshots (if relevant)**:  
slf4j error logging instrumentation doesn't work.

**Steps to reproduce** :

1. run application [slf4j-plugin-spring-boot-test](https://github.com/kananindzya/apm-example-use/tree/master/slf4j-plugin-spring-boot-test)
2. send GET request to [http://localhost:8080/log-error](http://localhost:8080/log-error)
3. error not captured.

**Errors in browser console (if relevant)**:

**Provide logs and/or server output (if relevant)**:

> <https://gist.github.com/kananindzya/5d91b5c1971c4be46f2861cd223ceddd>

```auto
[INFO] Building slf4j-plugin-spring-boot-test 2.0.2.RELEASE
[INFO] --------------------------------[jar]---------------------------------
[INFO] 
[INFO] --- maven-dependency-plugin:3.0.2:tree (default-cli) @ slf4j-plugin-spring-boot-test ---
[INFO] org.springframework.boot:slf4j-plugin-spring-boot-test:jar:2.0.2.RELEASE
[INFO] \- org.springframework.boot:spring-boot-starter-web:jar:2.0.2.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter:jar:2.0.2.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot:jar:2.0.2.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-autoconfigure:jar:2.0.2.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-logging:jar:2.0.2.RELEASE:compile
[INFO] | | +- ch.qos.logback:logback-classic:jar:1.2.3:compile
[INFO] | | | +- ch.qos.logback:logback-core:jar:1.2.3:compile
[INFO] | | | \- org.slf4j:slf4j-api:jar:1.7.25:compile
[INFO] | | +- org.apache.logging.log4j:log4j-to-slf4j:jar:2.10.0:compile
[INFO] | | | \- org.apache.logging.log4j:log4j-api:jar:2.10.0:compile
[INFO] | | \- org.slf4j:jul-to-slf4j:jar:1.7.25:compile
[INFO] | +- javax.annotation:javax.annotation-api:jar:1.3.2:compile
[INFO] | +- org.springframework:spring-core:jar:5.0.6.RELEASE:compile
[INFO] | | \- org.springframework:spring-jcl:jar:5.0.6.RELEASE:compile
[INFO] | \- org.yaml:snakeyaml:jar:1.19:runtime
[INFO] +- org.springframework.boot:spring-boot-starter-json:jar:2.0.2.RELEASE:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-databind:jar:2.9.5:compile
[INFO] | | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.9.0:compile
[INFO] | | \- com.fasterxml.jackson.core:jackson-core:jar:2.9.5:compile
[INFO] | +- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:jar:2.9.5:compile
[INFO] | +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.9.5:compile
[INFO] | \- com.fasterxml.jackson.module:jackson-module-parameter-names:jar:2.9.5:compile
[INFO] +- org.springframework.boot:spring-boot-starter-tomcat:jar:2.0.2.RELEASE:compile
[INFO] | +- org.apache.tomcat.embed:tomcat-embed-core:jar:8.5.31:compile
[INFO] | +- org.apache.tomcat.embed:tomcat-embed-el:jar:8.5.31:compile
[INFO] | \- org.apache.tomcat.embed:tomcat-embed-websocket:jar:8.5.31:compile
[INFO] +- org.hibernate.validator:hibernate-validator:jar:6.0.9.Final:compile
[INFO] | +- javax.validation:validation-api:jar:2.0.1.Final:compile
[INFO] | +- org.jboss.logging:jboss-logging:jar:3.3.2.Final:compile
[INFO] | \- com.fasterxml:classmate:jar:1.3.4:compile
[INFO] +- org.springframework:spring-web:jar:5.0.6.RELEASE:compile
[INFO] | \- org.springframework:spring-beans:jar:5.0.6.RELEASE:compile
[INFO] \- org.springframework:spring-webmvc:jar:5.0.6.RELEASE:compile
[INFO] +- org.springframework:spring-aop:jar:5.0.6.RELEASE:compile
[INFO] +- org.springframework:spring-context:jar:5.0.6.RELEASE:compile
[INFO] \- org.springframework:spring-expression:jar:5.0.6.RELEASE:compile

```

---

<div class="post-metadata">

**Author:** ![felixbarny](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/felixbarny/32/27341_2.png) [@felixbarny](https://discuss.elastic.co/u/felixbarny)\
**Post date:** [January 29, 2020, 12:12pm UTC](https://discuss.elastic.co/t/slf4j-error-not-captured/216987/2 "2020-01-29T12:12:05Z")

</div>

Could you tell me what's the value of `logger.getClass().getName()`?

> <https://github.com/kananindzya/apm-example-use/blob/d7d5162b6f1a4e8155f84603a721bf836fe0d602/slf4j-plugin-spring-boot-test/src/main/java/com/kananindzya/apm/java/slf4j/Slf4jErrorCaptureApplication.java#L22>

---

<div class="post-metadata">

**Author:** ![nugusbayevkk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nugusbayevkk/32/126683_2.png) [@nugusbayevkk](https://discuss.elastic.co/u/nugusbayevkk)\
**Post date:** [January 29, 2020, 12:15pm UTC](https://discuss.elastic.co/t/slf4j-error-not-captured/216987/3 "2020-01-29T12:15:01Z")

</div>

ch.qos.logback.classic.Logger

---

<div class="post-metadata">

**Author:** ![nugusbayevkk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nugusbayevkk/32/126683_2.png) [@nugusbayevkk](https://discuss.elastic.co/u/nugusbayevkk)\
**Post date:** [January 29, 2020, 4:03pm UTC](https://discuss.elastic.co/t/slf4j-error-not-captured/216987/4 "2020-01-29T16:03:33Z")

</div>

After adding a new condition to Slf4jLoggingInstrumentation#getTypeMatcher:

```auto
.or(named("ch.qos.logback.classic.Logger"));

```

It works fine.  
But why is hasSuperType method not instrumented `ch.qos.logback.classic.Logger`?

---

<div class="post-metadata">

**Author:** ![felixbarny](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/felixbarny/32/27341_2.png) [@felixbarny](https://discuss.elastic.co/u/felixbarny)\
**Post date:** [February 18, 2020, 9:10am UTC](https://discuss.elastic.co/t/slf4j-error-not-captured/216987/5 "2020-02-18T09:10:53Z")

</div>

Have you found out what the problem is? I'm also puzzled why the existing matcher

> <https://github.com/elastic/apm-agent-java/blob/9528d35842985671e90f20e9699ad27cc21a8f30/apm-agent-plugins/apm-error-logging-plugin/src/main/java/co/elastic/apm/agent/error/logging/Slf4jLoggingInstrumentation.java#L39-L41>

Does not match `ch.qos.logback.classic.Logger`, as it does implement `org.slf4j.Logger`:

> <https://github.com/qos-ch/logback/blob/7ee74ad132bf74ead68c5bb553f5353aa2588bb0/logback-classic/src/main/java/ch/qos/logback/classic/Logger.java#L38-L39>

---

<div class="post-metadata">

**Author:** ![nugusbayevkk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nugusbayevkk/32/126683_2.png) [@nugusbayevkk](https://discuss.elastic.co/u/nugusbayevkk)\
**Post date:** [February 24, 2020, 4:25am UTC](https://discuss.elastic.co/t/slf4j-error-not-captured/216987/6 "2020-02-24T04:25:23Z")

</div>

wow , I found solution. I sent PR.

> <https://github.com/elastic/apm-agent-java/pull/1049>

---

<div class="post-metadata">

**Author:** ![Sylvain\_Juge](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sylvain_juge/32/55521_2.png) [@Sylvain\_Juge](https://discuss.elastic.co/u/Sylvain_Juge)\
**Post date:** [February 26, 2020, 3:55pm UTC](https://discuss.elastic.co/t/slf4j-error-not-captured/216987/7 "2020-02-26T15:55:35Z")

</div>

You are amazing @nugusbayevkk ! I've just reviewed it and it will likely be merged in a future release (1.14.0 or the following).

---

<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 18, 2020, 12:00pm UTC](https://discuss.elastic.co/t/slf4j-error-not-captured/216987/8 "2020-03-18T12:00:28Z")

</div>

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