ramanathan1504 opened a new issue, #4491:
URL: https://github.com/apache/logging-log4j2/issues/4491
With Jackson 3 (`tools.jackson.dataformat:jackson-dataformat-yaml`) on the
classpath, alone or next to Jackson 2, `YamlConfigurationFactory` uses
`Jackson3YamlConfiguration`. That class parses with YAML 1.2 rules, so the
scalars `yes`, `Yes`, `YES`, `on`, `On` and `ON` reach plugin builders as
strings, and boolean attributes such as `additivity`, `append` and
`includeLocation` become `false`. With Jackson 2 the same configuration means
`true`, so adding Jackson 3 to an application silently changes a working
configuration, for example by truncating a log file configured with `append:
yes`. Nothing is reported through the status logger.
## Configuration
**Version:** 2.x branch at `ea28f5a78b` (2.27.0-SNAPSHOT); also `main` at
`2bb673f650`. Not in 2.26.1 or 3.0.0-beta3.
**Operating system:** macOS
**JDK:** OpenJDK 17.0.14; Jackson 3.2.3 (snakeyaml-engine 3.0.1), Jackson
2.20.0 (SnakeYAML 2.4)
## Logs
Jackson 2 only (2.26.1, and 2.x with Jackson 3 removed):
```
PASS additivity: yes expected=true (2 copies) observed=true (2 copies)
PASS additivity: on expected=true (2 copies) observed=true (2 copies)
PASS File append: yes expected=[seed, appended] observed=[seed, appended]
PASS Logger includeLocation: yes expected=main|loc observed=main|loc
```
2.x with Jackson 3, or with Jackson 2 and Jackson 3
(`Jackson3YamlConfiguration`):
```
FAIL additivity: yes expected=true (2 copies) observed=false (1 copies)
FAIL additivity: on expected=true (2 copies) observed=false (1 copies)
PASS additivity: true expected=true (2 copies) observed=true (2 copies)
FAIL File append: yes expected=[seed, appended] observed=[appended]
FAIL Logger includeLocation: yes expected=main|loc observed=|loc
```
The status logger prints nothing.
## Reproduction
`log4j2.yaml`:
```yaml
Configuration:
status: warn
Appenders:
File:
- name: FILE
fileName: app.log
append: false
PatternLayout:
pattern: "%c %m%n"
- name: SEED
fileName: seed.log
append: yes
PatternLayout:
pattern: "%m%n"
Loggers:
Logger:
- name: org.example
level: debug
additivity: yes
AppenderRef:
ref: FILE
- name: app
level: info
additivity: false
AppenderRef:
ref: SEED
Root:
level: error
AppenderRef:
ref: FILE
```
1. Put `log4j-core`,
`com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.20.0` and
`tools.jackson.dataformat:jackson-dataformat-yaml:3.2.3` on the classpath.
2. Write a line `seed` to `seed.log` before Log4j starts.
3. Run `LogManager.getLogger("org.example.Service").debug("m");
LogManager.getLogger("app").info("appended"); LogManager.shutdown();` with
`-Dlog4j2.configurationFile=log4j2.yaml`.
4. Expected: `app.log` has two `org.example.Service m` lines (additivity
true), and `seed.log` contains `seed` then `appended`. Observed: one line in
`app.log`, and `seed.log` contains only `appended`. With the Jackson 3 jar
removed you get the expected result.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]