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

LoggerEvents are lost when sending over the SocketAppender

    XMLWordPrintable

Details

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • 1.1.1
    • 1.0.13
    • logback-classic
    • None
    • Linux mobile-pc 3.10.17 #2 SMP Wed Oct 23 16:34:38 CDT 2013 x86_64 Intel(R) Core(TM)2 CPU T7200 @ 2.00GHz GenuineIntel GNU/Linux
      java version "1.7.0_45"

    Description

      On my machine I noticed that when sending multiple logging events to a SocketAppender, only the first event gets serialized and sent over the wire to a ServerSocketReceiver.

      Debuging the code, I found out that for sending loggingEvents the SocketAppender uses either a SynchronousQueue or an ArrayBlockingQueue in order to make producer-consumer and send serialized events to the socket. That BlockingQueue does behave erratically on my machine.

      To demonstrate that I included a small java test that will send 3 events to a SynchronousQueue and to an ArrayBlockingQueue and the output is this:

      ### start test SynchronousQueue###
      + appender thread started
      - send 3 events
      - no more events to be sent
      + received event 1
      + appender thread ended
      ### end test ###
      ### start test ArrayBlockingQueue[2]###
      + appender thread started
      - send 3 events
      - no more events to be sent
      ### end test ###
      ### start test ArrayBlockingQueue[3]###
      + appender thread started
      - send 3 events
      - no more events to be sent
      + received event 1
      + received event 2
      + received event 3
      + appender thread ended
      ### end test ###

      This shows that the SynchronousQueue only process the first event and ArrayBlockingQueue[2] does not work at all.

      Another test iteration:

      ### start test SynchronousQueue###
      + appender thread started
      - send 3 events
      - no more events to be sent
      + received event 1
      + appender thread ended
      ### end test ###
      ### start test ArrayBlockingQueue[2]###
      + appender thread started
      - send 3 events
      - no more events to be sent
      + received event 1
      + received event 2
      + appender thread ended
      ### end test ###
      ### start test ArrayBlockingQueue[3]###
      + appender thread started
      - send 3 events
      - no more events to be sent
      + received event 1
      + received event 2
      + received event 3
      + appender thread ended
      ### end test ###

      This time the SynchronousQueue only processes the first event and the ArrayBlockingQueue[2] processes the first 2 events.

      Attachments

        1. LogEvents.java
          2 kB
          Andrei I
        2. output.txt
          1 kB
          Andrei I
        3. sockappender.tar.gz
          2 kB
          Marvin Taboada

        Activity

          People

            tony19 Tony Trinh
            iandrei Andrei I
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: