ch.qos.logback.classic.net.SyslogAppender Java Examples

The following examples show how to use ch.qos.logback.classic.net.SyslogAppender. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LogbackFactory.java    From bither-desktop-java with Apache License 2.0 6 votes vote down vote up
public static SyslogAppender buildSyslogAppender(LoggingConfiguration.SyslogConfiguration syslog,
                                                 LoggerContext context,
                                                 String name,
                                                 String logFormat) {
    final SyslogAppender appender = new SyslogAppender();
    appender.setName(name);
    appender.setContext(context);
    appender.setSyslogHost(syslog.getHost());
    appender.setFacility(syslog.getFacility().toString());
    addThresholdFilter(appender, syslog.getThreshold());

    if (logFormat != null) {
        appender.setSuffixPattern(logFormat);
    }

    appender.start();

    return appender;
}
 
Example #2
Source File: LogbackFactory.java    From bither-desktop-java with Apache License 2.0 6 votes vote down vote up
public static SyslogAppender buildSyslogAppender(LoggingConfiguration.SyslogConfiguration syslog,
                                                 LoggerContext context,
                                                 String name,
                                                 String logFormat) {
    final SyslogAppender appender = new SyslogAppender();
    appender.setName(name);
    appender.setContext(context);
    appender.setSyslogHost(syslog.getHost());
    appender.setFacility(syslog.getFacility().toString());
    addThresholdFilter(appender, syslog.getThreshold());

    if (logFormat != null) {
        appender.setSuffixPattern(logFormat);
    }

    appender.start();

    return appender;
}
 
Example #3
Source File: VirtualHostSyslogLoggerImpl.java    From qpid-broker-j with Apache License 2.0 5 votes vote down vote up
@Override
protected Appender<ILoggingEvent> createAppenderInstance(Context context)
{
    SyslogAppender syslogAppender = new SyslogAppender();
    syslogAppender.setSyslogHost(_syslogHost);
    syslogAppender.setPort(_port);
    syslogAppender.setSuffixPattern(_suffixPattern);
    syslogAppender.setStackTracePattern(_stackTracePattern);
    syslogAppender.setThrowableExcluded(_throwableExcluded);
    syslogAppender.setFacility("USER");
    return syslogAppender;
}
 
Example #4
Source File: BrokerSyslogLoggerImpl.java    From qpid-broker-j with Apache License 2.0 5 votes vote down vote up
@Override
protected Appender<ILoggingEvent> createAppenderInstance(Context context)
{
    SyslogAppender syslogAppender = new SyslogAppender();
    syslogAppender.setSyslogHost(_syslogHost);
    syslogAppender.setPort(_port);
    syslogAppender.setSuffixPattern(_suffixPattern);
    syslogAppender.setStackTracePattern(_stackTracePattern);
    syslogAppender.setThrowableExcluded(_throwableExcluded);
    syslogAppender.setFacility("USER");
    return syslogAppender;
}
 
Example #5
Source File: LogSaveLocalHelper.java    From FimiX8-RE with MIT License 4 votes vote down vote up
public void run() {
    try {
        this.mProcess = Runtime.getRuntime().exec(this.cmds);
        this.mReader = new BufferedReader(new InputStreamReader(this.mProcess.getInputStream()), 1024);
        while (true) {
            String line = this.mReader.readLine();
            if (line == null) {
                break;
            } else if (!(line.length() == 0 || this.fos == null || !line.contains(this.mPid))) {
                if (LogSaveLocalHelper.tag == null || (LogSaveLocalHelper.tag != null && line.contains(LogSaveLocalHelper.tag))) {
                    this.fos.write((FormatDate.getFormatTime() + SyslogAppender.DEFAULT_STACKTRACE_PATTERN + line + "\r\n").getBytes());
                }
            }
        }
        if (this.mProcess != null) {
            this.mProcess.destroy();
            this.mProcess = null;
        }
        try {
            if (this.mReader != null) {
                this.mReader.close();
                this.mReader = null;
            }
            if (this.fos != null) {
                this.fos.close();
                this.fos = null;
            }
        } catch (Exception e2) {
            e2.printStackTrace();
        }
    } catch (Exception e) {
        e.printStackTrace();
        if (this.mProcess != null) {
            this.mProcess.destroy();
            this.mProcess = null;
        }
        try {
            if (this.mReader != null) {
                this.mReader.close();
                this.mReader = null;
            }
            if (this.fos != null) {
                this.fos.close();
                this.fos = null;
            }
        } catch (Exception e22) {
            e22.printStackTrace();
        }
    } catch (Throwable th) {
        if (this.mProcess != null) {
            this.mProcess.destroy();
            this.mProcess = null;
        }
        try {
            if (this.mReader != null) {
                this.mReader.close();
                this.mReader = null;
            }
            if (this.fos != null) {
                this.fos.close();
                this.fos = null;
            }
        } catch (Exception e222) {
            e222.printStackTrace();
        }
        throw th;
    }
}