Slf4j error not captured

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 :slight_smile:

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
  2. send GET request to http://localhost:8080/log-error
  3. error not captured.

Errors in browser console (if relevant):

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

[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

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

ch.qos.logback.classic.Logger

After adding a new condition to Slf4jLoggingInstrumentation#getTypeMatcher:

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

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

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

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

wow , I found solution. I sent PR.

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).

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