[ https://issues.apache.org/jira/browse/LOG4J2-1682?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16754664#comment-16754664 ]
Dmitry Chigileychik commented on LOG4J2-1682: --------------------------------------------- Issue is still exists in 2.11.1 {code:java} Logger loggerMessages = LogManager.getLogger("messages", new LocalizedMessageFactory("messages")); loggerMessages.info("test"); //prints "messages" loggerMessages.info("test", ""); //prints localized message Logger loggerRB = LogManager.getLogger("resourceBundle", new LocalizedMessageFactory(ResourceBundle.getBundle("messages"))); loggerRB.info("test"); //prints localized message loggerRB.info("test", ""); //prints localized message {code} The cause is incorrect constructor call: {code:java} @Override public Message newMessage(final String key) { if (resourceBundle == null) { return new LocalizedMessage(baseName, key); //LocalizedMessageFactory.java:72 } return new LocalizedMessage(resourceBundle, key); } {code} It calls {noformat} public LocalizedMessage(final String messagePattern, final Object arg) //LocalizedMessage.java:97{noformat} probably should call {noformat} public LocalizedMessage(final String baseName, final String key, final Object arg) //LocalizedMessage.java:101{noformat} > Logger using LocalizedMessageFactory prints key instead of message > ------------------------------------------------------------------ > > Key: LOG4J2-1682 > URL: https://issues.apache.org/jira/browse/LOG4J2-1682 > Project: Log4j 2 > Issue Type: Bug > Components: Core > Affects Versions: 2.7 > Reporter: Markus Waidhofer > Assignee: Gary Gregory > Priority: Major > Fix For: 2.8 > > Attachments: exampleLocalizedMessageFactory.zip > > > I am having a problem when logging localized messages. I use a Logger with > the LocalizedMessageFactory. However, everytime I pass the message key to the > logger, it prints the key itself instead of the message. If I pass additional > arguments to the logging method, the key gets translated correctly to the > message. > Example: > {code} > public class Showcase { > private static Logger logger = LogManager.getLogger(Showcase.class, new > LocalizedMessageFactory("messages")); > public static void main(String... args) { > logger.info("key.test"); // logs "key.test" > logger.info("key.test", ""); // prints message correctly > } > } > {code} > See attached project for a working example. -- This message was sent by Atlassian JIRA (v7.6.3#76005)