Java 类org.apache.log4j.net.SocketAppender 实例源码

项目:log4j-collector    文件:JmDnsUtil.java   
public static void main(String[] argv) throws Exception{
        JmDNS jmDNS = new JmDNSImpl(InetAddress.getLocalHost(), "karl");
        jmDNS.addServiceTypeListener(new DiscoverServices.SampleListener());
        jmDNS.addServiceListener(SocketAppender.ZONE, new DiscoverServices.SampleListener());
        //String type, String name, String subtype, int port, int weight, int priority, boolean persistent, String text
//        ServiceInfo serviceInfo = new ServiceInfoImpl("log4j", "log4j-agent", "log4j", 4561, 1, 1, true, "log4j-agent-text");
//        jmDNS.registerService(serviceInfo);
//        System.out.println(jmDNS);
    }
项目:daikon    文件:Log4j1Configurer.java   
private static Appender socketAppender() {
    final SocketAppender appender = new SocketAppender(AuditConfiguration.APPENDER_SOCKET_HOST.getString(),
            AuditConfiguration.APPENDER_SOCKET_PORT.getInteger());

    appender.setName("auditSocketAppender");
    appender.setLocationInfo(AuditConfiguration.LOCATION.getBoolean());

    return appender;
}
项目:nabs    文件:Loop.java   
public static void main(String[] args) {


  Logger root = Logger.getRootLogger();
  Logger cat = Logger.getLogger(Loop.class.getName());

  if(args.length != 2) 
    usage("Wrong number of arguments.");     

  String host = args[0];
  int port = 0;

  try {
    port = Integer.valueOf(args[1]).intValue();
  }
  catch (NumberFormatException e) {
      usage("Argument [" + args[1]  + "] is not in proper int form.");
  }

  SocketAppender sa = new SocketAppender(host, port);
  Layout layout = new PatternLayout("%5p [%t] %x %c - %m\n");
  Appender so = new ConsoleAppender(layout, "System.out");
  root.addAppender(sa);
  root.addAppender(so);

  int i = 0;

  while(true) {
    NDC.push(""+ (i++));
    cat.debug("Debug message.");
    root.info("Info message.");
    NDC.pop();
  }

}
项目:scheduling    文件:SocketBasedForwardingProvider.java   
public Appender getAppender() {
    return new SocketAppender(this.hostname, this.port);
}