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

Don't concatenate SYSLOG Messages

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

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.5
    • 2.6
    • Core
    • None
    • Linux, Java7, WebLogic 12

    Description

      Under heavy traffic load several SYSLOG messages can be concatenated, which is not correct.

      The problem is, several threads in AbstractOutputStreamAppender can reach in the next code write() before one thread reaches flush() (the readLock.lock() is not lock at all)

          @Override
          public void append(final LogEvent event) {
              readLock.lock();
              try {
                  final byte[] bytes = getLayout().toByteArray(event);
                  if (bytes.length > 0) {
                      manager.write(bytes);
                      if (this.immediateFlush || event.isEndOfBatch()) {
                          manager.flush();
                      }
                  }
              } catch (final AppenderLoggingException ex) {
                  error("Unable to write to stream " + manager.getName() + " for appender " + getName());
                  throw ex;
              } finally {
                  readLock.unlock();
              }
          }
      

      In DatagramOutputStream all messages are cumulated in instance variable private byte[] data;

      Synchronized methods don't help and in this case the synchronization in DatagramOutputStream is useless, as the correct synchronization should be provided in AbstractOutputStreamAppender.

      Attachments

        Activity

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

          People

            ggregory Gary D. Gregory
            vhudec Vladimir Hudec
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 8h
                8h
                Remaining:
                Remaining Estimate - 8h
                8h
                Logged:
                Time Spent - Not Specified
                Not Specified

                Slack

                  Issue deployment