You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "rgoers (via GitHub)" <gi...@apache.org> on 2026/10/18 20:43:23 UTC
[PR] Support Jackson 3 [logging-log4j2]
rgoers opened a new pull request, #4410:
URL: https://github.com/apache/logging-log4j2/pull/4410
YamlConfigurationFactory now supports Jackson 3.x through a new configuration class, Jackson3YamlConfiguration. When the Jackson 3 classes are on the classpath it uses them; otherwise it falls back to the existing Jackson 2.x YamlConfiguration.
The code compiles with JDK 17. I ran all 7 YAML files from log4j-core-test through both versions and they produce the same appenders, loggers and log output, apart from one difference described below. I didn’t add any unit tests, and nothing is committed.
**What changed**
- New class: Jackson3YamlConfiguration.java. It can’t extend JsonConfiguration because Jackson 3 uses different node classes, so it’s a standalone class with the same node-walking logic, updated for Jackson 3’s renamed methods. It doesn’t turn on any comment setting, because YAML supports comments on its own.
- YamlConfigurationFactory.java: checks for Jackson 3 first, then Jackson 2, and logs at debug level which one it picked.
**Things to Know**
- One parsing difference, and it’s an improvement: Jackson 3 reads YAML 1.2, where status: OFF stays the string OFF. Jackson 2 reads YAML 1.1 and turns it into boolean false, then logs “Invalid status level: false”. Values like on, off, yes and no will now come through as strings.
- Java version: Jackson 3 needs Java 17 or later. That’s safe here because the Jackson 3 classes are only loaded when they’re on the classpath.
- Choice when both are present: if an app has both Jackson 2 and 3, it now gets the Jackson 3 version.
--
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: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Support Jackson 3 [logging-log4j2]
Posted by "rgoers (via GitHub)" <gi...@apache.org>.
rgoers commented on PR #4410:
URL: https://github.com/apache/logging-log4j2/pull/4410#issuecomment-6301499607
> @rgoers: instead of creating a new configuration factory for a Jackson 3 based YAML configuration, what do you think about just backporting (copying) log4j-config-jackson and log4j-config-yaml from main?
@ppkarwasz Not a fan of back-porting those from 3.x. First, I wouldn't have created this PR at all if we would just release 3.0.0. Since 3.x was designed for Java 17 and Jackson 3 requires that I would have just said "upgrade to 3.x".
Second, it makes the problem of Jackson 2 vs Jackson 3 worse. If you have an app that has both present you will end up with two YamlConfiguration classes.
--
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: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Support Jackson 3 [logging-log4j2]
Posted by "ramanathan1504 (via GitHub)" <gi...@apache.org>.
ramanathan1504 merged PR #4410:
URL: https://github.com/apache/logging-log4j2/pull/4410
--
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: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Support Jackson 3 [logging-log4j2]
Posted by "andrei-ivanov (via GitHub)" <gi...@apache.org>.
andrei-ivanov commented on code in PR #4410:
URL: https://github.com/apache/logging-log4j2/pull/4410#discussion_r4308694824
##########
log4j-parent/pom.xml:
##########
@@ -89,6 +89,7 @@
<HdrHistogram.version>2.2.2</HdrHistogram.version>
<hsqldb.version>2.7.4</hsqldb.version>
<jackson-bom.version>2.22.2</jackson-bom.version>
+ <jackson3.version>3.1.4</jackson3.version>
Review Comment:
why not `3.2.3`?
--
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: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Support Jackson 3 [logging-log4j2]
Posted by "rgoers (via GitHub)" <gi...@apache.org>.
rgoers commented on PR #4410:
URL: https://github.com/apache/logging-log4j2/pull/4410#issuecomment-6309216477
> I will try to get Log4j 3.0.0 ready by Christmas: do we need this PR in that case? Is adding com.fasterxml.jackson.dataformat:jackson-dataformat-yaml in a Spring Boot 4 application a problem?
Having both Jackson 2 and Jackson 3 is only a problem if they are not configured to work the same (they don't by default) and the app ends up using both for similar things. Ideally the app itself should ONLY use Jackson 3. Spring 4.x will only use Jackson 3. But third party libraries might still depend on Jackson 2.
If 3.0 is actually released by Christmas then no, I would not bother with this.
--
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: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Support Jackson 3 [logging-log4j2]
Posted by "ppkarwasz (via GitHub)" <gi...@apache.org>.
ppkarwasz commented on PR #4410:
URL: https://github.com/apache/logging-log4j2/pull/4410#issuecomment-6303633058
> If you have an app that has both present you will end up with two YamlConfiguration classes.
Both classes interpret the configuration file in the same way (except the small differences between YAML 1.1 and 1.2), so this should not be a problem.
I will try to get Log4j `3.0.0` ready by Christmas: do we need this PR in that case? Is adding `com.fasterxml.jackson.dataformat:jackson-dataformat-yaml` in a Spring Boot 4 application a problem?
--
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: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Support Jackson 3 [logging-log4j2]
Posted by "ramanathan1504 (via GitHub)" <gi...@apache.org>.
ramanathan1504 commented on code in PR #4410:
URL: https://github.com/apache/logging-log4j2/pull/4410#discussion_r4333766385
##########
log4j-core/src/main/java/org/apache/logging/log4j/core/config/yaml/YamlConfigurationFactory.java:
##########
@@ -42,17 +54,33 @@ public class YamlConfigurationFactory extends ConfigurationFactory {
private final boolean isActive;
+ private final boolean useJackson3;
+
public YamlConfigurationFactory() {
- for (final String dependency : dependencies) {
- if (!Loader.isClassAvailable(dependency)) {
- LOGGER.debug(
- "Missing dependencies for Yaml support, ConfigurationFactory {} is inactive",
- getClass().getName());
- isActive = false;
- return;
+ if (areClassesAvailable(JACKSON3_DEPENDENCIES)) {
+ LOGGER.debug("Using Jackson 3.x for Yaml support");
+ useJackson3 = true;
+ isActive = true;
+ } else if (areClassesAvailable(JACKSON2_DEPENDENCIES)) {
+ LOGGER.debug("Using Jackson 2.x for Yaml support");
+ useJackson3 = false;
+ isActive = true;
Review Comment:
Fair point, a Jackson 3 build is an upgrade. Can the changelog entry say that YAML values are read as YAML 1.2 when Jackson 3 is present, so `on` and `yes` are no longer booleans?
--
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: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Support Jackson 3 [logging-log4j2]
Posted by "ramanathan1504 (via GitHub)" <gi...@apache.org>.
ramanathan1504 commented on PR #4410:
URL: https://github.com/apache/logging-log4j2/pull/4410#issuecomment-6286076593
With only Jackson 3 on the classpath, YAML configuration now loads, which fixes Spring Boot 4 apps.
With both versions present, `YamlConfigurationFactory` switches to Jackson 3 and `append: on` changes from `true` to `false`. Can Jackson 2 stay the first choice, and can we add a test for `Jackson3YamlConfiguration` and a changelog entry?
--
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: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Support Jackson 3 [logging-log4j2]
Posted by "andrei-ivanov (via GitHub)" <gi...@apache.org>.
andrei-ivanov commented on code in PR #4410:
URL: https://github.com/apache/logging-log4j2/pull/4410#discussion_r4310694061
##########
log4j-parent/pom.xml:
##########
@@ -89,6 +89,7 @@
<HdrHistogram.version>2.2.2</HdrHistogram.version>
<hsqldb.version>2.7.4</hsqldb.version>
<jackson-bom.version>2.22.2</jackson-bom.version>
+ <jackson3.version>3.1.4</jackson3.version>
Review Comment:
Thanks... in the meantime `3.2.4` was released 😁
--
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: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Support Jackson 3 [logging-log4j2]
Posted by "rgoers (via GitHub)" <gi...@apache.org>.
rgoers commented on code in PR #4410:
URL: https://github.com/apache/logging-log4j2/pull/4410#discussion_r4330232525
##########
log4j-core/src/main/java/org/apache/logging/log4j/core/config/yaml/YamlConfigurationFactory.java:
##########
@@ -42,17 +54,33 @@ public class YamlConfigurationFactory extends ConfigurationFactory {
private final boolean isActive;
+ private final boolean useJackson3;
+
public YamlConfigurationFactory() {
- for (final String dependency : dependencies) {
- if (!Loader.isClassAvailable(dependency)) {
- LOGGER.debug(
- "Missing dependencies for Yaml support, ConfigurationFactory {} is inactive",
- getClass().getName());
- isActive = false;
- return;
+ if (areClassesAvailable(JACKSON3_DEPENDENCIES)) {
+ LOGGER.debug("Using Jackson 3.x for Yaml support");
+ useJackson3 = true;
+ isActive = true;
+ } else if (areClassesAvailable(JACKSON2_DEPENDENCIES)) {
+ LOGGER.debug("Using Jackson 2.x for Yaml support");
+ useJackson3 = false;
+ isActive = true;
Review Comment:
This is a lose/lose scenario. If I add Jackson 3 to a build I am almost certainly upgrading and only leaving Jackson 2 for some third party library I cannot change. Because of that it makes more sense to me to have Jackson 3 be the default if it is present.
--
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: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Support Jackson 3 [logging-log4j2]
Posted by "ramanathan1504 (via GitHub)" <gi...@apache.org>.
ramanathan1504 commented on PR #4410:
URL: https://github.com/apache/logging-log4j2/pull/4410#issuecomment-6311058434
> > I will try to get Log4j 3.0.0 ready by Christmas: do we need this PR in that case? Is adding com.fasterxml.jackson.dataformat:jackson-dataformat-yaml in a Spring Boot 4 application a problem?
>
> Having both Jackson 2 and Jackson 3 is only a problem if they are not configured to work the same (they don't by default) and the app ends up using both for similar things. Ideally the app itself should ONLY use Jackson 3. Spring 4.x will only use Jackson 3. But third party libraries might still depend on Jackson 2.
>
> If 3.0 is actually released by Christmas then no, I would not bother with this. Spring Boot itself won't upgrade to Log4j 3.x in Spring Boot 4.x but we can certainly verify that it works.
@rgoers I am ready to give my support to `3.0.0`. please check the #3161 'PR' attachment file. I think it will helpful for us to move forward
--
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: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Support Jackson 3 [logging-log4j2]
Posted by "rgoers (via GitHub)" <gi...@apache.org>.
rgoers commented on PR #4410:
URL: https://github.com/apache/logging-log4j2/pull/4410#issuecomment-6316976314
@ramanathan1504 I have one more PR I need to submit to fix the breakage with the LoggerConfig Constructor Spring Boot uses.
--
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: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Support Jackson 3 [logging-log4j2]
Posted by "ramanathan1504 (via GitHub)" <gi...@apache.org>.
ramanathan1504 commented on code in PR #4410:
URL: https://github.com/apache/logging-log4j2/pull/4410#discussion_r4322504713
##########
log4j-parent/pom.xml:
##########
@@ -89,6 +89,7 @@
<HdrHistogram.version>2.2.2</HdrHistogram.version>
<hsqldb.version>2.7.4</hsqldb.version>
<jackson-bom.version>2.22.2</jackson-bom.version>
+ <jackson3.version>3.1.4</jackson3.version>
Review Comment:
yes, on a same time once its merged into `2.x` then `dependabot` will take care the `version` bump
--
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: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Support Jackson 3 [logging-log4j2]
Posted by "ramanathan1504 (via GitHub)" <gi...@apache.org>.
ramanathan1504 commented on code in PR #4410:
URL: https://github.com/apache/logging-log4j2/pull/4410#discussion_r4322634871
##########
log4j-core/src/main/java/org/apache/logging/log4j/core/config/yaml/YamlConfigurationFactory.java:
##########
@@ -42,17 +54,33 @@ public class YamlConfigurationFactory extends ConfigurationFactory {
private final boolean isActive;
+ private final boolean useJackson3;
+
public YamlConfigurationFactory() {
- for (final String dependency : dependencies) {
- if (!Loader.isClassAvailable(dependency)) {
- LOGGER.debug(
- "Missing dependencies for Yaml support, ConfigurationFactory {} is inactive",
- getClass().getName());
- isActive = false;
- return;
+ if (areClassesAvailable(JACKSON3_DEPENDENCIES)) {
+ LOGGER.debug("Using Jackson 3.x for Yaml support");
+ useJackson3 = true;
+ isActive = true;
+ } else if (areClassesAvailable(JACKSON2_DEPENDENCIES)) {
+ LOGGER.debug("Using Jackson 2.x for Yaml support");
+ useJackson3 = false;
+ isActive = true;
Review Comment:
Jackson 3 parses YAML as 1.2, so `on`, `yes`, `~` and `0x10` come through as plain strings. Apps that have both Jackson versions today get Jackson 2. Checking Jackson 2 first keeps those apps unchanged, and Jackson-3-only apps still get YAML support.
```suggestion
if (areClassesAvailable(JACKSON2_DEPENDENCIES)) {
LOGGER.debug("Using Jackson 2.x for Yaml support");
useJackson3 = false;
isActive = true;
} else if (areClassesAvailable(JACKSON3_DEPENDENCIES)) {
LOGGER.debug("Using Jackson 3.x for Yaml support");
useJackson3 = true;
isActive = true;
```
--
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: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Support Jackson 3 [logging-log4j2]
Posted by "ramanathan1504 (via GitHub)" <gi...@apache.org>.
ramanathan1504 commented on PR #4410:
URL: https://github.com/apache/logging-log4j2/pull/4410#issuecomment-6286179010
@rgoers for now i am added `port-main` label once `pr` raised for `main` then we will clear label from here. because sometime its slipped through. Thanks 👍🏾
--
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: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Support Jackson 3 [logging-log4j2]
Posted by "rgoers (via GitHub)" <gi...@apache.org>.
rgoers commented on code in PR #4410:
URL: https://github.com/apache/logging-log4j2/pull/4410#discussion_r4309706489
##########
log4j-parent/pom.xml:
##########
@@ -89,6 +89,7 @@
<HdrHistogram.version>2.2.2</HdrHistogram.version>
<hsqldb.version>2.7.4</hsqldb.version>
<jackson-bom.version>2.22.2</jackson-bom.version>
+ <jackson3.version>3.1.4</jackson3.version>
Review Comment:
Updated
--
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: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Support Jackson 3 [logging-log4j2]
Posted by "rgoers (via GitHub)" <gi...@apache.org>.
rgoers commented on code in PR #4410:
URL: https://github.com/apache/logging-log4j2/pull/4410#discussion_r4309343093
##########
log4j-parent/pom.xml:
##########
@@ -89,6 +89,7 @@
<HdrHistogram.version>2.2.2</HdrHistogram.version>
<hsqldb.version>2.7.4</hsqldb.version>
<jackson-bom.version>2.22.2</jackson-bom.version>
+ <jackson3.version>3.1.4</jackson3.version>
Review Comment:
I asked Claude and it said it picked that version as it was the latest one I had in my local Maven repo that had all the Jackson artifacts it needed. I will update it.
--
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: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Support Jackson 3 [logging-log4j2]
Posted by "ramanathan1504 (via GitHub)" <gi...@apache.org>.
ramanathan1504 commented on PR #4410:
URL: https://github.com/apache/logging-log4j2/pull/4410#issuecomment-6286674039
> @ramanathan1504: this already exists on `main`.
>
> @rgoers: instead of creating a new configuration factory for a Jackson 3 based YAML configuration, what do you think about just backporting (copying) `log4j-config-jackson` and `log4j-config-yaml` from `main`?
Oh sorry I missed it . thanks
--
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: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Support Jackson 3 [logging-log4j2]
Posted by "ppkarwasz (via GitHub)" <gi...@apache.org>.
ppkarwasz commented on PR #4410:
URL: https://github.com/apache/logging-log4j2/pull/4410#issuecomment-6286650825
@ramanathan1504: this already exists on `main`.
@rgoers: instead of creating a new configuration factory for a Jackson 3 based YAML configuration, what do you think about just backporting (copying) `log4j-config-jackson` and `log4j-config-yaml` from `main`?
--
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: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org