当前位置: 首页>>代码示例>>Java>>正文


Java SyslogMessage类代码示例

本文整理汇总了Java中com.cloudbees.syslog.SyslogMessage的典型用法代码示例。如果您正苦于以下问题:Java SyslogMessage类的具体用法?Java SyslogMessage怎么用?Java SyslogMessage使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SyslogMessage类属于com.cloudbees.syslog包,在下文中一共展示了SyslogMessage类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: publish

import com.cloudbees.syslog.SyslogMessage; //导入依赖的package包/类
@Override
public void publish(LogRecord record) {
    if (!isLoggable(record))
        return;

    String msg = getFormatter().format(record);

    Severity severity = LevelHelper.toSeverity(record.getLevel());
    if (severity == null)
        severity = this.severity;

    SyslogMessage message = new SyslogMessage()
            .withTimestamp(record.getMillis())
            .withSeverity(severity)
            .withAppName(this.appName)
            .withHostname(this.messageHostname)
            .withFacility(this.facility)
            .withMsg(msg);

    try {
        syslogMessageSender.sendMessage(message);
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
开发者ID:CloudBees-community,项目名称:syslog-java-client,代码行数:26,代码来源:SyslogHandler.java

示例2: send2

import com.cloudbees.syslog.SyslogMessage; //导入依赖的package包/类
@Ignore
@Test
public void send2() throws Exception {

    SyslogMessage msg = new SyslogMessage()
            .withAppName("my-app")
            .withFacility(Facility.USER)
            .withHostname("my-hostname")
            .withMsg("my message over tcp éèà " + new Timestamp(System.currentTimeMillis()))
            .withSeverity(Severity.INFORMATIONAL)
            .withTimestamp(System.currentTimeMillis());

    TcpSyslogMessageSender messageSender = new TcpSyslogMessageSender();
    messageSender.setSyslogServerHostname("logs2.papertrailapp.com");
    messageSender.setSyslogServerPort(46022);
    messageSender.setMessageFormat(MessageFormat.RFC_3164);
    messageSender.setSsl(true);

    System.out.println(msg.toSyslogMessage(messageSender.getMessageFormat()));

    messageSender.sendMessage(msg);
}
 
开发者ID:CloudBees-community,项目名称:syslog-java-client,代码行数:23,代码来源:TcpSyslogMessageSenderTest.java

示例3: sendOverSSL

import com.cloudbees.syslog.SyslogMessage; //导入依赖的package包/类
@Ignore
@Test
public void sendOverSSL() throws Exception {

    SyslogMessage msg = new SyslogMessage()
            .withAppName("my-app")
            .withFacility(Facility.USER)
            .withHostname("my-hostname")
            .withMsg("my message over tcp ssl éèà " + new Timestamp(System.currentTimeMillis()))
            .withSeverity(Severity.INFORMATIONAL)
            .withTimestamp(System.currentTimeMillis());

    TcpSyslogMessageSender messageSender = new TcpSyslogMessageSender();
    messageSender.setSyslogServerHostname("logs2.papertrailapp.com");
    messageSender.setSyslogServerPort(46022);
    messageSender.setMessageFormat(MessageFormat.RFC_3164);
    messageSender.setSsl(true);

    System.out.println(msg.toSyslogMessage(messageSender.getMessageFormat()));

    messageSender.sendMessage(msg);
}
 
开发者ID:CloudBees-community,项目名称:syslog-java-client,代码行数:23,代码来源:TcpSyslogMessageSenderTest.java

示例4: append

import com.cloudbees.syslog.SyslogMessage; //导入依赖的package包/类
@Override
protected void append(E loggingEvent) {
  try {
    SyslogMessage syslogMessage =
        syslogConfig.getProtocol().getSyslogMessage(syslogConfig).withSeverity(Severity.fromNumericalCode(getSeverityForEvent(loggingEvent)))
            .withMsg(layout.doLayout(loggingEvent)).withFacility(Facility.USER).withAppName(syslogConfig.getProgramName())
            .withHostname(InetAddress.getLocalHost().getHostName());
    syslogMessageSender.sendMessage(syslogMessage);
  } catch (IOException e) {
    e.printStackTrace();
  }
}
 
开发者ID:serioussam,项目名称:syslogappender,代码行数:13,代码来源:SyslogAppender.java

示例5: logEvent0

import com.cloudbees.syslog.SyslogMessage; //导入依赖的package包/类
@Override
protected void logEvent0(PciAuditEvent event) {
    if (!initialized) {
        LOG.error("syslog audit not initialiazed");
        return;
    }

    CharArrayWriter msg = event.toCharArrayWriter(prefix);
    final int n = msg.size();
    if (n > maxMessageLength) {
        LOG.warn("syslog message exceeds the maximal allowed length: {} > {}, ignore it",
                n, maxMessageLength);
        return;
    }

    SyslogMessage sm = new SyslogMessage();
    sm.setFacility(syslog.getDefaultFacility());
    if (notEmpty(localname)) {
        sm.setHostname(localname);
    }

    sm.setSeverity(getSeverity(event.level()));
    sm.setMsg(msg);

    try {
        syslog.sendMessage(sm);
    } catch (IOException ex) {
        LOG.error("could not send syslog message: {}", ex.getMessage());
        LOG.debug("could not send syslog message", ex);
    }
}
 
开发者ID:xipki,项目名称:xitk,代码行数:32,代码来源:SyslogAuditServiceImpl.java

示例6: sendMessage

import com.cloudbees.syslog.SyslogMessage; //导入依赖的package包/类
/**
 * Send the given {@link com.cloudbees.syslog.SyslogMessage}.
 *
 * @param message the message to send
 * @throws IOException
 */
void sendMessage(@Nonnull SyslogMessage message) throws IOException;
 
开发者ID:CloudBees-community,项目名称:syslog-java-client,代码行数:8,代码来源:SyslogMessageSender.java


注:本文中的com.cloudbees.syslog.SyslogMessage类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。