[ https://issues.apache.org/jira/browse/LOG4J2-3177?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17434894#comment-17434894 ]
Richard Eckart de Castilho commented on LOG4J2-3177: ---------------------------------------------------- Ok, so I have switched to the {{release-2.x}} branch and to a Java 1.8 and that makes things a lot better, but I still cannot run {{org.apache.logging.slf4j.LoggerTest.debugWithParms()}} in either Eclipse or IntelliJ because when I try, I get told: {noformat} org.apache.logging.log4j.LoggingException: log4j-slf4j-impl cannot be present with log4j-to-slf4j at org.apache.logging.slf4j.Log4jLoggerFactory.validateContext(Log4jLoggerFactory.java:60) at org.apache.logging.slf4j.Log4jLoggerFactory.newLogger(Log4jLoggerFactory.java:44) at org.apache.logging.slf4j.Log4jLoggerFactory.newLogger(Log4jLoggerFactory.java:1) at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:53) at org.apache.logging.slf4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:1) at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:358) at org.apache.logging.slf4j.LoggerTest.<init>(LoggerTest.java:53) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at org.junit.runners.BlockJUnit4ClassRunner.createTest(BlockJUnit4ClassRunner.java:250) at org.junit.runners.BlockJUnit4ClassRunner.createTest(BlockJUnit4ClassRunner.java:260) at org.junit.runners.BlockJUnit4ClassRunner$2.runReflectiveCall(BlockJUnit4ClassRunner.java:309) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:306) at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63) at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329) at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293) at org.apache.logging.log4j.junit.LoggerContextRule$1.evaluate(LoggerContextRule.java:126) at org.junit.rules.RunRules.evaluate(RunRules.java:20) at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306) at org.junit.runners.ParentRunner.run(ParentRunner.java:413) at org.junit.runner.JUnitCore.run(JUnitCore.java:137) at org.junit.runner.JUnitCore.run(JUnitCore.java:115) at org.junit.vintage.engine.execution.RunnerExecutor.execute(RunnerExecutor.java:43) at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183) at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193) at java.util.Iterator.forEachRemaining(Iterator.java:116) at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801) at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482) at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472) at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150) at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173) at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:485) at org.junit.vintage.engine.VintageTestEngine.executeAllChildren(VintageTestEngine.java:82) at org.junit.vintage.engine.VintageTestEngine.execute(VintageTestEngine.java:73) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:108) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:96) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:84) at org.eclipse.jdt.internal.junit5.runner.JUnit5TestReference.run(JUnit5TestReference.java:98) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:40) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:541) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:768) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:464) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:210) {noformat} And indeed, {{log4j-to-slf4j}} is a test dependency of the {{log4j-slf4j-impl}} module. Is this supposed to work or is something here in limbo? > 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)