View Javadoc

1   /**
2    * Logback: the generic, reliable, fast and flexible logging framework.
3    * 
4    * Copyright (C) 1999-2006, QOS.ch
5    * 
6    * This library is free software, you can redistribute it and/or modify it under
7    * the terms of the GNU Lesser General Public License as published by the Free
8    * Software Foundation.
9    */
10  
11  // Contributors: Dan MacDonald <dan@redknee.com>
12  package ch.qos.logback.access.net;
13  
14  import java.net.InetAddress;
15  
16  import ch.qos.logback.access.spi.AccessEvent;
17  import ch.qos.logback.core.net.SocketAppenderBase;
18  
19  /**
20   * Sends {@link AccessEvent} objects to a remote a log server, usually a
21   * {@link SocketNode}.
22   * 
23   * For more information about this appender, please refer to the online manual at
24   * http://logback.qos.ch/manual/appenders.html#AccessSocketAppender
25   *  
26   * @author Ceki G&uuml;lc&uuml;
27   * @author S&eacute;bastien Pennec
28   * 
29   */
30  
31  public class SocketAppender extends SocketAppenderBase<AccessEvent> {
32    
33    public SocketAppender() {
34    }
35  
36    /**
37     * Connects to remote server at <code>address</code> and <code>port</code>.
38     */
39    public SocketAppender(InetAddress address, int port) {
40      this.address = address;
41      this.remoteHost = address.getHostName();
42      this.port = port;
43    }
44  
45    /**
46     * Connects to remote server at <code>host</code> and <code>port</code>.
47     */
48    public SocketAppender(String host, int port) {
49      this.port = port;
50      this.address = getAddressByName(host);
51      this.remoteHost = host;
52    }
53    
54    @Override
55    protected void postProcessEvent(AccessEvent event) {
56      AccessEvent ae = (AccessEvent)event;
57      ae.prepareForDeferredProcessing();
58    }
59  
60  }