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


Java Facility类代码示例

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


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

示例1: SyslogHandler

import com.cloudbees.syslog.Facility; //导入依赖的package包/类
public SyslogHandler() {
    super();
    LogManager manager = LogManager.getLogManager();

    String cname = getClass().getName();

    UdpSyslogMessageSender udpSender = new UdpSyslogMessageSender();
    udpSender.setSyslogServerHostname(LogManagerHelper.getStringProperty(manager, cname + ".syslogServerHostname", SyslogMessageSender.DEFAULT_SYSLOG_HOST));
    udpSender.setSyslogServerPort(LogManagerHelper.getIntProperty(manager, cname + ".syslogServerPort", SyslogMessageSender.DEFAULT_SYSLOG_PORT));

    appName = LogManagerHelper.getStringProperty(manager, cname + ".appName", this.appName);
    udpSender.setDefaultAppName(appName);
    facility = Facility.fromLabel(LogManagerHelper.getStringProperty(manager, cname + ".facility", this.facility.label()));
    udpSender.setDefaultFacility(facility);
    severity = Severity.fromLabel(LogManagerHelper.getStringProperty(manager, cname + ".severity", this.severity.label()));
    udpSender.setDefaultSeverity(severity);
    messageHostname = LogManagerHelper.getStringProperty(manager, cname + ".messageHostname", this.messageHostname);
    udpSender.setDefaultMessageHostname(messageHostname);

    this.syslogMessageSender = udpSender;
}
 
开发者ID:CloudBees-community,项目名称:syslog-java-client,代码行数:22,代码来源:SyslogHandler.java

示例2: send2

import com.cloudbees.syslog.Facility; //导入依赖的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.Facility; //导入依赖的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.Facility; //导入依赖的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: send

import com.cloudbees.syslog.Facility; //导入依赖的package包/类
@Test
public void send() throws Exception {
    TcpSyslogMessageSender messageSender = new TcpSyslogMessageSender();
    messageSender.setDefaultMessageHostname("mysecretkey");
    messageSender.setDefaultAppName("myapp");
    messageSender.setDefaultFacility(Facility.USER);
    messageSender.setDefaultSeverity(Severity.INFORMATIONAL);
    messageSender.setSyslogServerHostname("logs2.papertrailapp.com");
    messageSender.setSyslogServerPort(46022);
    messageSender.setMessageFormat(MessageFormat.RFC_3164);
    messageSender.setSsl(true);
    messageSender.sendMessage("unit test message over tcp éèà " + getClass() + " - " + new Timestamp(System.currentTimeMillis()));
}
 
开发者ID:CloudBees-community,项目名称:syslog-java-client,代码行数:14,代码来源:TcpSyslogMessageSenderTest.java

示例6: send

import com.cloudbees.syslog.Facility; //导入依赖的package包/类
@Test
public void send() throws Exception {
    UdpSyslogMessageSender messageSender = new UdpSyslogMessageSender();
    messageSender.setDefaultMessageHostname("mysecretkey");
    messageSender.setDefaultAppName("myapp");
    messageSender.setDefaultFacility(Facility.USER);
    messageSender.setDefaultSeverity(Severity.INFORMATIONAL);
    // messageSender.setSyslogServerHostname("cloudbees1.papertrailapp.com");
    messageSender.setSyslogServerHostname("127.0.0.1");
    messageSender.setSyslogServerPort(18977);
    messageSender.sendMessage("unit test message éèà " + getClass() + " - " + new Timestamp(System.currentTimeMillis()));
}
 
开发者ID:CloudBees-community,项目名称:syslog-java-client,代码行数:13,代码来源:UpdSyslogMessageSenderTest.java

示例7: getFacility

import com.cloudbees.syslog.Facility; //导入依赖的package包/类
public Facility getFacility() {
    return facility;
}
 
开发者ID:CloudBees-community,项目名称:syslog-java-client,代码行数:4,代码来源:SyslogHandler.java

示例8: setFacility

import com.cloudbees.syslog.Facility; //导入依赖的package包/类
public void setFacility(Facility facility) {
    this.facility = facility;
}
 
开发者ID:CloudBees-community,项目名称:syslog-java-client,代码行数:4,代码来源:SyslogHandler.java

示例9: main

import com.cloudbees.syslog.Facility; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    final int THREADS_COUNT = 10;
    final int ITERATION_COUNT = 1000;

    ExecutorService executorService = Executors.newFixedThreadPool(THREADS_COUNT);

    final UdpSyslogMessageSender messageSender = new UdpSyslogMessageSender();
    messageSender.setDefaultMessageHostname("mysecretkey");
    messageSender.setDefaultAppName("myapp");
    messageSender.setDefaultFacility(Facility.USER);
    messageSender.setDefaultSeverity(Severity.INFORMATIONAL);
    messageSender.setSyslogServerHostname("logs2.papertrailapp.com");
    // messageSender.setSyslogServerHostname("127.0.0.1");
    messageSender.setSyslogServerPort(46022);

    final AtomicInteger count = new AtomicInteger();


    for (int i = 0; i < THREADS_COUNT; i++) {
        final String prefix = "thread-" + i + "-udp-msg-";

        Runnable command = new Runnable() {
            @Override
            public void run() {
                for (int j = 0; j < ITERATION_COUNT; j++) {
                    try {
                        messageSender.sendMessage(prefix + j);
                    } catch (IOException e) {
                        System.err.println("ERROR in " + prefix);
                        e.printStackTrace();
                        break;
                    }
                }
            }
        };

        executorService.execute(command);
    }

    executorService.shutdown();
    executorService.awaitTermination(1, TimeUnit.MINUTES);
    System.out.println("sent " + messageSender.getSendCount() + " in " + messageSender.getSendDurationInMillis() + "ms");
    System.out.println("bye");
}
 
开发者ID:CloudBees-community,项目名称:syslog-java-client,代码行数:45,代码来源:UdpSyslogMessageSenderLoadTest.java


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