[
https://issues.apache.org/jira/browse/LOG4J2-3177?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17433823#comment-17433823
]
Ralph Goers edited comment on LOG4J2-3177 at 10/25/21, 3:32 PM:
----------------------------------------------------------------
Are you compiling with Java 14? The release 2.x branch requires using Maven
toolchains. Most of Log4j requires Java 8 while there are some modules that use
Java 9 or higher. Java 8 has to be the default. Here is my toolchains.xml just
for reference.
{code:java}
<?xml version="1.0" encoding="UTF8"?>
<toolchains>
<!-- JDK toolchains -->
<toolchain>
<type>jdk</type>
<provides>
<version>1.7</version>
<vendor>sun</vendor>
</provides>
<configuration>
<jdkHome>/Library/Java/JavaVirtualMachines/java7/Contents/Home</jdkHome>
</configuration>
</toolchain>
<toolchain>
<type>jdk</type>
<provides>
<version>1.8</version>
<vendor>sun</vendor>
</provides>
<configuration>
<jdkHome>/Library/Java/JavaVirtualMachines/java8/Contents/Home</jdkHome>
</configuration>
</toolchain>
<toolchain>
<type>jdk</type>
<provides>
<version>9</version>
<vendor>sun</vendor>
</provides>
<configuration>
<jdkHome>/Library/Java/JavaVirtualMachines/java9/Contents/Home</jdkHome>
</configuration>
</toolchain>
<toolchain>
<type>jdk</type>
<provides>
<version>11</version>
<vendor>sun</vendor>
</provides>
<configuration>
<jdkHome>/Library/Java/JavaVirtualMachines/Java11/Contents/Home</jdkHome>
</configuration>
</toolchain>
<toolchain>
<type>jdk</type>
<provides>
<version>14</version>
<vendor>sun</vendor>
</provides>
<configuration>
<jdkHome>/Library/Java/JavaVirtualMachines/Java14/Contents/Home</jdkHome>
</configuration>
</toolchain>
<!-- other toolchains -->
</toolchains>
{code}
You can thank the folks at Oracle for this being so difficult. Supporting both
Java 8 and Java 9+ became difficult. At the moment the master branch is worse
due to its attempt to fully support the Java Platform Module System but since
it will only support Java 11+ I anticipate being able to clean that up before
it is released.
was (Author: [email protected]):
Are you compiling with Java 14? The release 2.x branch requires using Maven
toolchains. Most of Log4j requires Java 8 while there are some modules that use
Java 9 or higher. Java 8 has to be the default. Here is my toolchains.xml just
for reference.
{code:java}
<?xml version="1.0" encoding="UTF8"?>
<toolchains>
<!-- JDK toolchains -->
<toolchain>
<type>jdk</type>
<provides>
<version>1.7</version>
<vendor>sun</vendor>
</provides>
<configuration>
<jdkHome>/Library/Java/JavaVirtualMachines/java7/Contents/Home</jdkHome>
</configuration>
</toolchain>
<toolchain>
<type>jdk</type>
<provides>
<version>1.8</version>
<vendor>sun</vendor>
</provides>
<configuration>
<jdkHome>/Library/Java/JavaVirtualMachines/java8/Contents/Home</jdkHome>
</configuration>
</toolchain>
<toolchain>
<type>jdk</type>
<provides>
<version>9</version>
<vendor>sun</vendor>
</provides>
<configuration>
<jdkHome>/Library/Java/JavaVirtualMachines/java9/Contents/Home</jdkHome>
</configuration>
</toolchain>
<toolchain>
<type>jdk</type>
<provides>
<version>11</version>
<vendor>sun</vendor>
</provides>
<configuration>
<jdkHome>/Library/Java/JavaVirtualMachines/Java11/Contents/Home</jdkHome>
</configuration>
</toolchain>
<toolchain>
<type>jdk</type>
<provides>
<version>14</version>
<vendor>sun</vendor>
</provides>
<configuration>
<jdkHome>/Library/Java/JavaVirtualMachines/Java14/Contents/Home</jdkHome>
</configuration>
</toolchain>
<!-- other toolchains -->
</toolchains>
{code}
> Log4jLogger swallows stack trace if throwable is only present in parameter
> list and not given explicitly
> --------------------------------------------------------------------------------------------------------
>
> Key: LOG4J2-3177
> URL: https://issues.apache.org/jira/browse/LOG4J2-3177
> Project: Log4j 2
> Issue Type: Bug
> Components: SLF4J Bridge
> Affects Versions: 2.14.1
> Reporter: Richard Eckart de Castilho
> Priority: Major
> Attachments: Screenshot 2021-10-25 at 07.36.19.png, Screenshot
> 2021-10-25 at 07.39.17.png
>
>
> I have the feeling that this code below from the Log4jLogger class has a bug.
> I believe the intention of the code is to use the throwable extracted from
> the message params of the parametrized message if the {{throwable}} parameter
> was not explicitly provided to the method. But to accomplish this, the
> condition would need to be {{if (throwable == null)}} in the code snippet
> below. This seems to cause exception stack traces to be swallowed if the
> throwable is only provided in the params array but not explicitly in the
> {{throwable}} argument.
> {code}
> public void log(final Marker marker, final String fqcn, final int level,
> final String message, final Object[] params, Throwable throwable) {
> ...
> msg = new ParameterizedMessage(message, params, throwable);
> if (throwable != null) { // I am pretty sure the idea was to use a "=="
> here and not a "!="
> throwable = msg.getThrowable();
> }
> ...
> }
> {code}
> Source (permalink master at reporting time):
> https://github.com/apache/logging-log4j2/blob/1a62186816bdd05ba420e01f6ee5a2b139a41816/log4j-slf4j-impl/src/main/java/org/apache/logging/slf4j/Log4jLogger.java#L371-L374
> Source (latest master):
> https://github.com/apache/logging-log4j2/blob/master/log4j-slf4j-impl/src/main/java/org/apache/logging/slf4j/Log4jLogger.java#L371-L374
> I hit the issue in Log4J 2.10.0 but checking the GitHub repo, it appears that
> this code is still present on the current master branch (see permalink above).
--
This message was sent by Atlassian Jira
(v8.3.4#803005)