No SLF4J providers were found
tkaiser opened this issue · 5 comments
just as a quick FYI, i followed the instructions in this stackoverflow: https://stackoverflow.com/questions/46080448/logging-in-aws-lambda-with-slf4j
i kept getting this in cloudwatch:
http://www.slf4j.org/codes.html#noProviders
what finally worked for me was adding the following dependencies into my own build.gradle:
implementation("org.slf4j:slf4j-api:1.8.0-beta2")
implementation("ch.qos.logback:logback-classic:1.3.0-alpha4") {
exclude("com.sun.mail:javax.mail")
}
implementation ("javax.activation:activation:1.1.1")
implementation("org.jlib:jlib-awslambda-logback:1.0.0")
i'm using java11 and gradle 5.6.4 (kotlin syntax). for some reason the runtimeOnly stuff wasnt working and i also wasn't getting transitive dependencies properly. the javax.activation stuff is related to java8+ as far as i could tell.
since i saw you asking in vain for more details on that stackoverflow answer, i thought this might be of interest.
Hi @tkaiser and thanks a lot for reporting this issue. I believe it is related to AWS Lambda now allowing to use Java 11, while this library was created and tested on Java 8, when that was the only viable option with AWS Lambda. Thank you as well for providing your workaround. I will try to incorporate it into the library in order to provide the ease of use it was designed for in the first place.
Hi @tkaiser and @dmitry-weirdo,
I finally got to investigate the issue. I created a project using a Gradle Kotlin DSL build depending on this library, as you described. I tried targeting Java 8, then Java 11. I deployed both versions as lambda functions and both worked fine out of the box.
Here are the relevant parts of my build.gradle.kts:
plugins {
id("java-library")
id("com.github.johnrengelman.shadow") version "2.0.4"
}
// ...
java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
// ...
implementation("org.slf4j:slf4j-api:1.8.0-beta2")
runtimeOnly("org.jlib:jlib-awslambda-logback:1.0.0")
...
tasks {
assemble {
dependsOn(shadowJar)
}
}
...Could you please share the exact configuration that leads to issues in your case? I'll be more than happy to dig into it.
Update:
I now tested with the configuration you provided and, again, had no issues:
# ./gradlew --version
------------------------------------------------------------
Gradle 5.6.4
------------------------------------------------------------
Build time: 2019-11-01 20:42:00 UTC
Revision: dd870424f9bd8e195d614dc14bb140f43c22da98
Kotlin: 1.3.41
Groovy: 2.5.4
Ant: Apache Ant(TM) version 1.9.14 compiled on March 12 2019
JVM: 11.0.6 (Oracle Corporation 11.0.6+10)
OS: Linux 4.19.76-linuxkit amd64
# java --version
openjdk 11.0.6 2020-01-14
OpenJDK Runtime Environment 18.9 (build 11.0.6+10)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.6+10, mixed mode)
Closed the issue for now, please feel free to reopen if you're still experiencing problems. Thanks.
I'm seeing this issue in both j8 and j11. I have a lambda to which I need to move to logback for json logging. But before I do that I wanted to get logback in place of the default log4j logging . I first got the SLF4J: No SLF4J providers were found. with the default configuration. Also none of the configuration above worked for me. I then I tried:
implementation 'org.slf4j:slf4j-api:1.8.0-beta4'
implementation ('ch.qos.logback:logback-classic:1.3.0-alpha4') {
exclude group: 'ch.qos.logback', module: 'logback-core'
}
compile 'ch.qos.logback:logback-core:1.3.0-alpha4'
implementation 'org.jlib:jlib-awslambda-logback:1.0.0'
Which got me pass the no SLF4J provider issue. But now the AWSRequestId is not present in my logout. Also the class that is logging s a service class of the actually lambda handler
I'm seeing this problem currently with the Java 11 runtime. I'm using sbt with the following deps:
"org.slf4j" % "slf4j-api" % "1.7.36",
"org.jlib" % "jlib-awslambda-logback" % "1.0.0",