Uploaded image for project: 'logback'
  1. logback
  2. LOGBACK-1318

LoggingEvent.prepareForDeferredProcessing doesn't need to call LoggingEvent.getFormattedMessage

    XMLWordPrintable

Details

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • None
    • logback-classic
    • None

    Description

      LoggingEvent.prepareForDeferredProcessing should be called when using asynchronous or deferred logging. The code is as blow. The first line may cause log event serialization, which is time-cosuming when the message is big. Actually, it is not need to have this line of code. The code was added in https://github.com/qos-ch/logback/commit/dfd340815e36f475cd014fd85915dbbafa739d4f by Ceki Gulcu in 2010. The comment is "all logback-classic and logback-core tests pass". Actually, no test case failure if this line is removed. I would suggest to remove this line, so that the log event will not be serialized untile the logger thread really need the formatted message.

      public void prepareForDeferredProcessing() {
          this.getFormattedMessage();
          this.getThreadName();
          // fixes http://jira.qos.ch/browse/LBCLASSIC-104
          this.getMDCPropertyMap();
      }

      Attachments

        Activity

          People

            logback-dev Logback dev list
            William William Li
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: