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

Allow custom message creation via a message factory

Agile BoardAttach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.0-beta3
    • 2.0-beta4
    • API
    • None

    Description

      My goal here is to be able to say:

      Logger log = LogManager.getLogger(Foo.class, new MyMessageFactory())

      Where MyMessageFactory extends a MessageFactory:

      and overrides:

      public Message newMessage(String message, Object... params)

      { return new ParameterizedMessage(message, params); }

      as:

      public Message newMessage(String message, Object... params)

      { return new StringFormattedMessage(message, params); }

      which would let me use native Java formatting instead of {} formatting /easily/

      I've attach the idea as the beginning of patch, which is missing the LogManager bits.

      Maybe we need a sub-interface of Message for param message, which would make me want to rename the class ParameterizedMessage to SimpleParameterizedMessage.

      Attachments

        1. log4j2-133.diff
          34 kB
          Gary D. Gregory
        2. LogManagerAPI.diff
          22 kB
          Gary D. Gregory

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            Unassigned Unassigned
            ggregory Gary D. Gregory
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment