Example #1
0
 private void dispatchEvents(LoggerContext lc) {
   try {
     socket.setSoTimeout(acceptConnectionTimeout);
     ObjectInputStream ois = new ObjectInputStream(socket.getInputStream());
     socket.setSoTimeout(0);
     addInfo(receiverId + "connection established");
     while (true) {
       ILoggingEvent event = (ILoggingEvent) ois.readObject();
       Logger remoteLogger = lc.getLogger(event.getLoggerName());
       if (remoteLogger.isEnabledFor(event.getLevel())) {
         remoteLogger.callAppenders(event);
       }
     }
   } catch (EOFException ex) {
     addInfo(receiverId + "end-of-stream detected");
   } catch (IOException ex) {
     addInfo(receiverId + "connection failed: " + ex);
   } catch (ClassNotFoundException ex) {
     addInfo(receiverId + "unknown event class: " + ex);
   } finally {
     CloseUtil.closeQuietly(socket);
     socket = null;
     addInfo(receiverId + "connection closed");
   }
 }
Example #2
0
 /** {@inheritDoc} */
 protected void onStop() {
   if (socket != null) {
     CloseUtil.closeQuietly(socket);
   }
 }