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

Allow custom message creation via a message factory

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.0-beta3
    • Fix Version/s: 2.0-beta4
    • Component/s: API
    • Labels:
      None
    • Environment:

      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. LogManagerAPI.diff
          22 kB
          Gary Gregory
        2. log4j2-133.diff
          34 kB
          Gary Gregory

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved: