https://github.com/digipost/jul-to-slf4j-junit-extension
JUnit Jupiter Extension to set up the jul-to-slf4j bridge in JUnit tests
https://github.com/digipost/jul-to-slf4j-junit-extension
Last synced: about 2 months ago
JSON representation
JUnit Jupiter Extension to set up the jul-to-slf4j bridge in JUnit tests
- Host: GitHub
- URL: https://github.com/digipost/jul-to-slf4j-junit-extension
- Owner: digipost
- License: apache-2.0
- Created: 2023-03-07T23:48:49.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2025-02-13T21:04:58.000Z (3 months ago)
- Last Synced: 2025-02-13T21:34:03.759Z (3 months ago)
- Language: Java
- Size: 18.6 KB
- Stars: 0
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://maven-badges.herokuapp.com/maven-central/no.digipost/jul-to-slf4j-junit-extension)
[](https://github.com/digipost/jul-to-slf4j-junit-extension/actions)
[](LICENSE)# Digipost jul-to-slf4j bridge JUnit Extension
This is a JUnit Jupiter extension which will load the
[jul-to-slf4j bridge handler](https://www.slf4j.org/legacy.html#jul-to-slf4j)
for tests, to get logging done using the `java.util.logging` API routed to
SLF4J.The preferred way to use this is to declare it as a test-dependency, and include
a `junit-platform.properties` file in the classpath for your tests, e.g. in
`src/test/resources/junit-platform.properties`:
```properties
junit.jupiter.extensions.autodetection.enabled=true
```This will enable the extension to be automatically loaded by JUnit Jupiter, and
you do not need to specify the extension in every test.Alternatively, if extension autodetection can not be enabled for your project
for any reason, the extension can be loaded using
```java
@ExtendWith(JavaLoggingToSlf4JExtension.class)
```The extension detects if the jul-to-slf4j bridge handler is already installed
(e.g. by Spring Boot or other tooling which sets up the Slf4J stack), and will
not reinstall the bridge handler in such case.