Return-Path: X-Original-To: apmail-logging-log4j-dev-archive@www.apache.org Delivered-To: apmail-logging-log4j-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D6ADE11568 for ; Wed, 6 Aug 2014 05:47:12 +0000 (UTC) Received: (qmail 36786 invoked by uid 500); 6 Aug 2014 05:47:12 -0000 Delivered-To: apmail-logging-log4j-dev-archive@logging.apache.org Received: (qmail 36736 invoked by uid 500); 6 Aug 2014 05:47:12 -0000 Mailing-List: contact log4j-dev-help@logging.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Log4J Developers List" Reply-To: "Log4J Developers List" Delivered-To: mailing list log4j-dev@logging.apache.org Received: (qmail 36726 invoked by uid 99); 6 Aug 2014 05:47:12 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 06 Aug 2014 05:47:12 +0000 Date: Wed, 6 Aug 2014 05:47:12 +0000 (UTC) From: "Remko Popma (JIRA)" To: log4j-dev@logging.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Resolved] (LOG4J2-632) Formatter logger mixes up arguments MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/LOG4J2-632?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Remko Popma resolved LOG4J2-632. -------------------------------- Resolution: Not a Problem Problem is in the format string as Ralph indicated. {code} public class StrFormat { public static void main(String[] args) { String fmt1 = "It is %1s in %2s"; String fmt2 = "It is %1$tF in %2s"; String fmt3 = "It is %1$tF in %2$s"; System.out.println(String.format(fmt1, new Date(), "Switzerland")); System.out.println(String.format(fmt2, new Date(), "Switzerland")); System.out.println(String.format(fmt3, new Date(), "Switzerland")); } } {code} Output: {code} It is Wed Aug 06 14:43:42 JST 2014 in Switzerland It is 2014-08-06 in Wed Aug 06 14:43:42 JST 2014 It is 2014-08-06 in Switzerland {code} > Formatter logger mixes up arguments > ----------------------------------- > > Key: LOG4J2-632 > URL: https://issues.apache.org/jira/browse/LOG4J2-632 > Project: Log4j 2 > Issue Type: Bug > Affects Versions: 2.0-rc1 > Reporter: Alexandre Gattiker > > {code} > public class Example { > private final static Logger FORMATTER_LOGGER = LogManager.getFormatterLogger(Example.class); > public static void main(String[] args) { > FORMATTER_LOGGER.log(ERROR, "It is %1s in %2s", new Date(), "Switzerland"); // works fine > FORMATTER_LOGGER.log(ERROR, "It is %1$tF in %2s", new Date(), "Switzerland"); // ignores "Switzerland", uses %1 value instead > } > } > {code} > {noformat} > 13:53:21.350 [main] ERROR com.example.Example - It is Tue May 06 13:53:21 CEST 2014 in Switzerland > 13:53:21.355 [main] ERROR com.example.Example - It is 2014-05-06 in Tue May 06 13:53:21 CEST 2014 > {noformat} -- This message was sent by Atlassian JIRA (v6.2#6252) --------------------------------------------------------------------- To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org For additional commands, e-mail: log4j-dev-help@logging.apache.org