Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Logback: the reliable, generic, fast and flexible logging framework. Copyright (C) 1999-2011, All rights reserved. This program and the accompanying materials are dual-licensed under either the terms of the Eclipse Public License v1.0 as published by the Eclipse Foundation or (per the licensee's choosing) under the terms of the GNU Lesser General Public License version 2.1 as published by the Free Software Foundation.
SyslogOutputStream is a wrapper around the class so that it behaves like an
public class SyslogOutputStream extends OutputStream {

The maximum length after which we discard the existing string buffer and start anew.
  private static final int MAX_LEN = 1024;
  private InetAddress address;
  private DatagramSocket ds;
  final private int port;
  public SyslogOutputStream(String syslogHostint portthrows UnknownHostException,
      SocketException {
    this. = InetAddress.getByName(syslogHost);
    this. = port;
    this. = new DatagramSocket();
  public void write(byte[] byteArrayint offsetint lenthrows IOException {
  public void flush() throws IOException {
    byte[] bytes = .toByteArray();
    DatagramPacket packet = new DatagramPacket(bytesbytes.length,
    // clean up for next round
    if (.size() > ) {
       = new ByteArrayOutputStream();
    } else {
    // after a failure, it can happen that bytes.length is zero
    // in that case, there is no point in sending out an empty message/
    if(bytes.length == 0) {
    if (this. != null) {
  public void close() {
     = null;
     = null;
  public int getPort() {
    return ;
  public void write(int bthrows IOException {
New to GrepCode? Check out our FAQ X