Skip to content

Commit

Permalink
chore: Better error message for when there is a sl4j version mismatch (
Browse files Browse the repository at this point in the history
  • Loading branch information
johanandren authored Mar 25, 2024
1 parent 9953975 commit 94fffa0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,16 @@ import akka.actor.testkit.typed.internal.CapturingAppender
*/
final class LogCapturing extends TestRule {
// eager access of CapturingAppender to fail fast if misconfigured
private val capturingAppender = CapturingAppender.get("")
private val capturingAppender =
try {
CapturingAppender.get("")
} catch {
case iae: IllegalArgumentException if iae.getMessage.contains("it was a [org.slf4j.helpers.NOPLogger]") =>
throw new RuntimeException(
"SLF could not initialize the logger, this is may be caused by accidentally having the slf4j-api dependency " +
"evicted/bumped to 2.2 by transitive dependencies while Akka only supports slf4j-api 1.7",
iae)
}

private val myLogger = LoggerFactory.getLogger(classOf[LogCapturing])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,16 @@ import akka.actor.testkit.typed.internal.CapturingAppender
trait LogCapturing extends BeforeAndAfterAll { self: TestSuite =>

// eager access of CapturingAppender to fail fast if misconfigured
private val capturingAppender = CapturingAppender.get("")
private val capturingAppender =
try {
CapturingAppender.get("")
} catch {
case iae: IllegalArgumentException if iae.getMessage.contains("it was a [org.slf4j.helpers.NOPLogger]") =>
throw new RuntimeException(
"SLF could not initialize the logger, this is may be caused by accidentally having the slf4j-api dependency " +
"evicted/bumped to 2.2 by transitive dependencies while Akka only supports slf4j-api 1.7",
iae)
}

private val myLogger = LoggerFactory.getLogger(classOf[LogCapturing])

Expand Down

0 comments on commit 94fffa0

Please sign in to comment.