View Javadoc
1   /**
2    * Logback: the reliable, generic, fast and flexible logging framework.
3    * Copyright (C) 1999-2015, QOS.ch. All rights reserved.
4    *
5    * This program and the accompanying materials are dual-licensed under
6    * either the terms of the Eclipse Public License v1.0 as published by
7    * the Eclipse Foundation
8    *
9    *   or (per the licensee's choosing)
10   *
11   * under the terms of the GNU Lesser General Public License version 2.1
12   * as published by the Free Software Foundation.
13   */
14  // Contributors: Dan MacDonald <dan@redknee.com>
15  package ch.qos.logback.classic.net;
16  
17  import ch.qos.logback.classic.spi.ILoggingEvent;
18  import ch.qos.logback.core.net.AbstractSocketAppender;
19  import ch.qos.logback.core.spi.PreSerializationTransformer;
20  
21  /**
22   * Sends {@link ILoggingEvent} objects to a remote a log server, usually a
23   * {@link SocketNode}.
24   * 
25   * For more information on this appender, please refer to the online manual
26   * at http://logback.qos.ch/manual/appenders.html#SocketAppender
27   * 
28   * @author Ceki G&uuml;lc&uuml;
29   * @author S&eacute;bastien Pennec
30   */
31  
32  public class SocketAppender extends AbstractSocketAppender<ILoggingEvent> {
33  
34      private static final PreSerializationTransformer<ILoggingEvent> pst = new LoggingEventPreSerializationTransformer();
35  
36      private boolean includeCallerData = false;
37  
38      public SocketAppender() {
39      }
40  
41      @Override
42      protected void postProcessEvent(ILoggingEvent event) {
43          if (includeCallerData) {
44              event.getCallerData();
45          }
46      }
47  
48      public void setIncludeCallerData(boolean includeCallerData) {
49          this.includeCallerData = includeCallerData;
50      }
51  
52      public PreSerializationTransformer<ILoggingEvent> getPST() {
53          return pst;
54      }
55  
56  }