001/** 002 * Logback: the reliable, generic, fast and flexible logging framework. 003 * Copyright (C) 1999-2015, QOS.ch. All rights reserved. 004 * 005 * This program and the accompanying materials are dual-licensed under 006 * either the terms of the Eclipse Public License v1.0 as published by 007 * the Eclipse Foundation 008 * 009 * or (per the licensee's choosing) 010 * 011 * under the terms of the GNU Lesser General Public License version 2.1 012 * as published by the Free Software Foundation. 013 */ 014package ch.qos.logback.core.recovery; 015 016import java.io.IOException; 017import java.io.OutputStream; 018import java.net.SocketException; 019import java.net.UnknownHostException; 020 021import ch.qos.logback.core.net.SyslogOutputStream; 022 023public class ResilientSyslogOutputStream extends ResilientOutputStreamBase { 024 025 String syslogHost; 026 int port; 027 028 public ResilientSyslogOutputStream(String syslogHost, int port) throws UnknownHostException, SocketException { 029 this.syslogHost = syslogHost; 030 this.port = port; 031 super.os = new SyslogOutputStream(syslogHost, port); 032 this.presumedClean = true; 033 } 034 035 @Override 036 String getDescription() { 037 return "syslog [" + syslogHost + ":" + port + "]"; 038 } 039 040 @Override 041 OutputStream openNewOutputStream() throws IOException { 042 return new SyslogOutputStream(syslogHost, port); 043 } 044 045 @Override 046 public String toString() { 047 return "c.q.l.c.recovery.ResilientSyslogOutputStream@" + System.identityHashCode(this); 048 } 049 050}