當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。