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.
 package ch.qos.logback.classic.pattern;
 import java.util.Date;
 public class SyslogStartConverter extends ClassicConverter {
   long lastTimestamp = -1;
   String timesmapStr = null;
   int facility;
   public void start() {
     int errorCount = 0;
     String facilityStr = getFirstOption();
     if (facilityStr == null) {
       addError("was expecting a facility string as an option");
      = SyslogAppenderBase.facilityStringToint(facilityStr);
     try {
       // hours should be in 0-23, see also
        = new SimpleDateFormat("MMM dd HH:mm:ss"new DateFormatSymbols(.));
     } catch (IllegalArgumentException e) {
       addError("Could not instantiate SimpleDateFormat"e);
     if(errorCount == 0) {
   public String convert(ILoggingEvent event) {
     StringBuilder sb = new StringBuilder();
     int pri =  + LevelToSyslogSeverity.convert(event);
     sb.append(' ');
     sb.append(' ');
     return sb.toString();

This method gets the network name of the machine we are running on. Returns "UNKNOWN_LOCALHOST" in the unlikely case where the host name cannot be found.

String the name of the local host
   public String getLocalHostname() {
     try {
       InetAddress addr = InetAddress.getLocalHost();
       return addr.getHostName();
     } catch (UnknownHostException uhe) {
       addError("Could not determine local host name"uhe);
       return "UNKNOWN_LOCALHOST";
   String computeTimeStampString(long now) {
     synchronized (this) {
       if (now != ) {
          = now;
          = .format(new Date(now));
       return ;
New to GrepCode? Check out our FAQ X