本文整理匯總了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;
}
示例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);
}
示例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);
}
示例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();
}
}
示例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()));
}
示例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()));
}
示例7: getFacility
import com.cloudbees.syslog.Facility; //導入依賴的package包/類
public Facility getFacility() {
return facility;
}
示例8: setFacility
import com.cloudbees.syslog.Facility; //導入依賴的package包/類
public void setFacility(Facility facility) {
this.facility = facility;
}
示例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");
}