Example #1
0
 public void close() throws IOException {
   final LogEvent event = new DefaultLogEventMapper().map(message);
   StringWriter w2 = out2;
   if (w2 == null) {
     w2 = (StringWriter) out;
   }
   String ct = (String) message.get(Message.CONTENT_TYPE);
   StringBuilder payload = new StringBuilder();
   try {
     writePayload(payload, w2, ct);
   } catch (Exception ex) {
     // ignore
   }
   event.setPayload(payload.toString());
   sender.send(event);
   message.setContent(Writer.class, out);
   super.close();
 }
Example #2
0
    public void onClose(CachedOutputStream cos) {
      final LogEvent event = new DefaultLogEventMapper().map(message);
      try {
        String encoding = (String) message.get(Message.ENCODING);
        StringBuilder payload = new StringBuilder();
        writePayload(payload, cos, encoding, event.getContentType());
        event.setPayload(payload.toString());
      } catch (Exception ex) {
        // ignore
      }

      sender.send(event);
      try {
        // empty out the cache
        cos.lockOutputStream();
        cos.resetOut(null, false);
      } catch (Exception ex) {
        // ignore
      }
      message.setContent(OutputStream.class, origStream);
    }