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

SocketAppenderBase should use a SocketFactory and allow subclasses to provide it

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.0.10
    • Fix Version/s: 1.0.11
    • Labels:
      None

      Description

      In SocketAppenderBase.connect, the Socket constructor is invoked directly to create a new socket. This makes it difficult for a subclass to have any influence over the creation of sockets (e.g. to use an SSL socket).

      If SocketAppenderBase declared at method such as this:

      protected SocketFactory getSocketFactory() {
      return SocketFactory.getDefault()
      }

      and used it in the connect() implementation...

      ...
      oos = new ObjectOutputStream(getSocketFactory().createSocket(address, port).getOutputStream());
      ...

      then a subclass could override it with, for example, an appropriately configured SSLSocketFactory...

      public class MySSLSocketAppender extends SocketAppender {
      ...
      protected SocketFactory getSocketFactory()

      { return mySslContext.getSocketFactory() }

      ...
      }

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                logback-dev Logback dev list
                Reporter:
                ceharris Carl Harris
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: