You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -10,23 +11,29 @@ A Java library for unit-testing logging.
10
11
11
12
Sometimes, writing specific information into its log(file) is an important part of an application's functionality. As such, it's probably a good idea to cover that behavior in the application's unit tests.
12
13
13
-
Although there are other solutions to achieve this (like e.g. using mocks and test for the methods to be called), LogUnit aims at testing on another level: right within the logging framework, so you can still see all your logs while testing. No matter how you generate your log messages in your project, if they end up in the popular [Slf4j](https://www.slf4j.org) library or in java.util.logging, you can use LogUnit (\*).
14
+
Although there are other solutions to achieve this (like e.g. using mocks and test for the methods to be called), LogUnit aims at testing on another level: right within the logging framework, so you can still see all your logs while testing. No matter how you generate your log messages in your project, if they end up in one of the supported logging frameworks, you can use LogUnit.
14
15
15
16
16
17
## Requirements
17
18
18
19
- Java 8 or above
19
20
- JUnit 5
20
-
- You must be using Slf4j or java.util.logging for logging
21
-
- You must be using Logback or java.util.logging as log binding (\*)
21
+
- You must be using one of the supported logging frameworks at test runtime
22
+
- You may use [Slf4j](https://www.slf4j.org) or your logging framework's native API (or anything else that makes your log events end up in your logging framework at runtime)
23
+
24
+
### Supported logging frameworks
25
+
26
+
- java.util.logging (the JDK's logging API)
27
+
-[Logback](https://logback.qos.ch)
28
+
-[Log4j2](https://logging.apache.org/log4j/2.x/)
22
29
23
30
24
31
## Installation
25
32
26
33
Add LogUnit to your project's dependencies.
27
34
28
35
* Declare `logunit-core` as compile-time dependency
29
-
* Declare the binding-specific module (e.g. `logunit-logback`or `logunit-jul` (\*)) as test-runtime dependency
36
+
* Declare the binding-specific module (e.g. `logunit-logback`, `logunit-log4j2`or `logunit-jul`) as test-runtime dependency
@@ -97,11 +107,7 @@ See [LogCapturerWithLogbackTest.java](https://github.com/netmikey/logunit/blob/m
97
107
98
108
## Architecture
99
109
100
-
LogUnit wants to remain as transparent as possible. That means your unit tests' logs should stay the way they are (oratleastascloseaspossible). As such, we don't want to bring and force our own Slf4j binding implementation onto consuming projects.
101
-
102
-
Therefor, LogUnit's architecture is similar to Slf4j's: At it's core, it uses the Slf4jAPI but in order to work at runtime, it provides binding-specific modules for hooking into the most popular logging frameworks (\*).
103
-
110
+
LogUnit wants to remain as transparent and easy to setup as possible. That means your unit tests' logs should stay the way they are (oratleastascloseaspossible). As such, we don't want to bring and force our own Slf4j binding implementation onto consuming projects.
104
111
105
-
## Limitations
112
+
Therefor, LogUnit's architecture is similar to Slf4j's: At it's core, it uses the Slf4j API but in order to work at runtime, it provides binding-specific modules for hooking into the most popular logging frameworks.
106
113
107
-
(\*) Currently, only Logback and java.util.logging are supported.
0 commit comments