google / google/flogger

Not able to use slf4j-backend

Open
#69 14 comments 1 reaction 0 assignees View on GitHub
P3
Dominant language
Java
Stars
1.5k
Forks
133
Avg merge
6m
Merged PRs (30d)
7

Description

Using these dependencies:

```xml

com.google.flogger
flogger
0.4

com.google.flogger
flogger-slf4j-backend
0.4

ch.qos.logback
logback-classic
1.2.2

```

should be enough if I understand https://github.com/google/flogger#how-to-use-flogger correctly.

But this test:

```java
public class FloggerTest {

private static final FluentLogger log = FluentLogger.forEnclosingClass();

@Test
public void test() {
log.atWarning().log("Test: %s", "message");
}
}
```

fails with:

```
java.lang.ExceptionInInitializerError
at com.google.common.flogger.backend.Platform.getCallerFinder(Platform.java:142)
at com.google.common.flogger.FluentLogger.forEnclosingClass(FluentLogger.java:70)
at test.FloggerTest.(FloggerTest.java:10)
Caused by: java.lang.IllegalStateException: No logging platforms found:
com.google.common.flogger.backend.system.DefaultPlatform: java.lang.ClassNotFoundException: com.google.common.flogger.backend.system.DefaultPlatform
at com.google.common.flogger.backend.Platform$LazyHolder.loadFirstAvailablePlatform(Platform.java:99)
at com.google.common.flogger.backend.Platform$LazyHolder.(Platform.java:67)
... 25 more
```

According to https://github.com/google/flogger/blob/master/log4j/src/main/java/com/google/common/flogger/backend/log4j/Log4jBackendFactory.java#L30 you have to set the `flogger.backend_factory` system property, so I started Java with `-Dflogger.backend_factory=com.google.common.flogger.backend.slf4j.Slf4jBackendFactory#getInstance`, but this resulted in the same exception.

What am I missing?

(the whole project can be found at: https://github.com/PascalSchumacher/flogger-slf4j-test)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.