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

SocketAppenderBase should use a SocketFactory and allow subclasses to provide it

    XMLWordPrintable

Details

    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

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: