Uploaded image for project: 'Log4j 2'
  1. Log4j 2
  2. LOG4J2-1682

Logger using LocalizedMessageFactory prints key instead of message

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.7
    • 2.8
    • Core
    • None

    Description

      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:

      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
          }
      }
      

      See attached project for a working example.

      Attachments

        1. exampleLocalizedMessageFactory.zip
          3 kB
          Markus Waidhofer

        Activity

          People

            ggregory Gary D. Gregory
            w4rumy Markus Waidhofer
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: