本文整理汇总了Java中com.cloudbees.syslog.sender.UdpSyslogMessageSender类的典型用法代码示例。如果您正苦于以下问题:Java UdpSyslogMessageSender类的具体用法?Java UdpSyslogMessageSender怎么用?Java UdpSyslogMessageSender使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
UdpSyslogMessageSender类属于com.cloudbees.syslog.sender包,在下文中一共展示了UdpSyslogMessageSender类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: SyslogHandler
import com.cloudbees.syslog.sender.UdpSyslogMessageSender; //导入依赖的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: test
import com.cloudbees.syslog.sender.UdpSyslogMessageSender; //导入依赖的package包/类
@Test
public void test(){
Logger logger = Logger.getLogger(getClass().getName());
logger.setLevel(Level.FINEST);
UdpSyslogMessageSender messageSender = new UdpSyslogMessageSender();
SyslogHandler syslogHandler = new SyslogHandler(messageSender, Level.ALL, null);
messageSender.setSyslogServerHostname("cloudbees1.papertrailapp.com");
messageSender.setSyslogServerPort(18977);
syslogHandler.setMessageHostname("mysecretkey");
syslogHandler.setAppName("SyslogHandlerTest");
logger.addHandler(syslogHandler);
logger.fine("hello world 2");
}