[ https://issues.apache.org/jira/browse/LOG4J2-1688?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15654263#comment-15654263 ]
Stefan Hammelbeck commented on LOG4J2-1688: ------------------------------------------- *Example code:* {code} package de.deutschepost.rs.zd.tv.model; import java.util.Arrays; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.BlockJUnit4ClassRunner; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * Bug description: * * We are using SLF4J over Log4j Version 2.7. * * Calling <code>org.slf4j.Logger.error(someFormat, args)</code> <b>twice</b> with an <code>Object[] args</code> causes all elements * of <code>args</code> to be set to <code>null</code>. * */ @RunWith(BlockJUnit4ClassRunner.class) public class CheckLog4j2Test { @Test public void testLog4j2() { // Argument-array creation int limit = 33; Object[] args = createArray(limit); Object[] originalArgs = Arrays.copyOf(args, args.length); System.out.println("args " + Arrays.toString(args)); // Logger definition String someFormat = "test {}"; Logger logger = LoggerFactory.getLogger(this.getClass()); // First logging of args logger.error(someFormat, args); // Only the first element (args[0]) of args will be logged - why? Assert.assertArrayEquals(originalArgs, args); System.out.println("args are still ok: " + Arrays.toString(args)); // Bug: The second logging of args sets all elements of args to null logger.error(someFormat, args); System.out.println("args " + Arrays.toString(args)); Assert.assertArrayEquals(originalArgs, args); } /** * @param size * @return */ private static Object[] createArray(int size) { Object[] args = new Object[size]; for (int i = 0; i < args.length; i++) { args[i] = i; } return args; } } {code} > Multiple loggings of arguments are setting these arguments to null > ------------------------------------------------------------------ > > Key: LOG4J2-1688 > URL: https://issues.apache.org/jira/browse/LOG4J2-1688 > Project: Log4j 2 > Issue Type: Bug > Affects Versions: 2.7 > Reporter: Stefan Hammelbeck > > We are using SLF4J over log4j Version 2.7. > Calling {{org.slf4j.Logger.error(someFormat, args)}} *twice* with an > {{Object[] args}} causes all elements of {{args}} to be set to {{null}}. -- This message was sent by Atlassian JIRA (v6.3.4#6332) --------------------------------------------------------------------- To unsubscribe, e-mail: log4j-dev-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-dev-h...@logging.apache.org