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

Logger using LocalizedMessageFactory prints key instead of message

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.7
    • Fix Version/s: 2.8
    • Component/s: Core
    • Labels:
      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

          Activity

            People

            • Assignee:
              garydgregory Gary Gregory
              Reporter:
              w4rumy Markus Waidhofer
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: