Commit b0d82c2
committed
StatusLogger: Write to stderr by default
`StatusLogger` messages used to be written to stderr by default. Since
2.23.0, they are being written to stdout. This is a significant
regression. As a rule, stderr is for humans, and stdout is for programs.
The pipe operator redirects stdout by default, and a CLI utility can
have its output corrupted because Log4j2 emitted a status message to
stdout. For example, consider a program that emits JSON and has its
output piped to `jq`: after upgrading to Log4j 2.23.0 or later, this
program will cease to work correctly unless the StatusLogger is
reconfigured to not emit anything, or is explicitly configured to write
to stderr.
This regression can be fixed by calling the two-parameter constructor
variant of `StatusConsoleListener` from `StatusLogger`. A simple test
case has been added that captures stdout/stderr and ensures that the
default `StatusLogger` is not emitting anything to stdout.
Fixes #3665.1 parent c84ff4a commit b0d82c2
File tree
3 files changed
+67
-1
lines changed- log4j-api-test/src/test/java/org/apache/logging/log4j/status
- log4j-api/src/main/java/org/apache/logging/log4j/status
- src/changelog/.2.x.x
3 files changed
+67
-1
lines changedLines changed: 56 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
531 | 531 | | |
532 | 532 | | |
533 | 533 | | |
534 | | - | |
| 534 | + | |
535 | 535 | | |
536 | 536 | | |
537 | 537 | | |
| |||
Lines changed: 10 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
0 commit comments