Log4j 2
  1. Log4j 2
  2. LOG4J2-122

Socket/Syslog appenders silently lose first message after socket disconnect

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0-beta2
    • Fix Version/s: 2.0-beta4
    • Component/s: Appenders
    • Labels:
      None
    • Environment:

      Java 1.6.0_24

      Description

      The Socket and Syslog appenders silently lose the first log message sent after the destination server socket disconnects. This occurs regardless if suppressExceptions is set to true or false.

      1. TestSilentMessageLossBehavior.java
        3 kB
        Scott Severtson
      2. log4j2.xml
        0.4 kB
        Scott Severtson

        Activity

        Hide
        Ralph Goers added a comment -

        I added your application as a unit test but modified the server to call setSoLinger(true, 0) and then verified that exceptions are properly thrown.

        Show
        Ralph Goers added a comment - I added your application as a unit test but modified the server to call setSoLinger(true, 0) and then verified that exceptions are properly thrown.
        Hide
        Ralph Goers added a comment -

        Please see http://docs.oracle.com/javase/1.5.0/docs/guide/net/articles/connection_release.html. I 've taken your java class and added it as a unit test. However, I've found that the only way to solve the problem is in code that needs to be added to the socket server. You simply need to add socket.setSoLinger(true, 0) to the socket. I've gone ahead and also added it to the socket in the TCPSocketManager but that made no difference.

        Show
        Ralph Goers added a comment - Please see http://docs.oracle.com/javase/1.5.0/docs/guide/net/articles/connection_release.html . I 've taken your java class and added it as a unit test. However, I've found that the only way to solve the problem is in code that needs to be added to the socket server. You simply need to add socket.setSoLinger(true, 0) to the socket. I've gone ahead and also added it to the socket in the TCPSocketManager but that made no difference.
        Hide
        Scott Severtson added a comment -

        Sample log4j2.xml configuration file to demonstrate the behavior.

        Show
        Scott Severtson added a comment - Sample log4j2.xml configuration file to demonstrate the behavior.
        Hide
        Scott Severtson added a comment -

        Demonstration app to show the behavior.

        Show
        Scott Severtson added a comment - Demonstration app to show the behavior.

          People

          • Assignee:
            Ralph Goers
            Reporter:
            Scott Severtson
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development