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

StringBuilderFormattable Messages should used cached formatted message if it exists

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.7
    • Fix Version/s: 2.8
    • Component/s: API
    • Labels:
      None

      Description

      When logging asynchronously, Message::getFormattedMessage is called to give Message implementations a chance to take a snapshot of mutable objects before the message is passed to another thread. (See LOG4J2-763, LOG4J2-1718. Exceptions are Messages implementing ReusableMessage or AsynchronouslyFormattable.)

      Some Messages implement StringBuilderFormattable to avoid creating temporary objects in the Layout.

      The StringBuilderFormattable::formatTo(StringBuilder) method should be implemented such that it first checks if a cached formatted message string exists. If so, this string should be appended to the StringBuilder. If no cached message string exists logging is done synchronously and the formatted message can safely be created afresh.

      This bug exists in:

      • ObjectMessage
      • SimpleMessage

        Attachments

          Activity

            People

            • Assignee:
              remkop@yahoo.com Remko Popma
              Reporter:
              remkop@yahoo.com Remko Popma
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: