本文整理汇总了Java中org.apache.log4j.net.SyslogAppender类的典型用法代码示例。如果您正苦于以下问题:Java SyslogAppender类的具体用法?Java SyslogAppender怎么用?Java SyslogAppender使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SyslogAppender类属于org.apache.log4j.net包,在下文中一共展示了SyslogAppender类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: append
import org.apache.log4j.net.SyslogAppender; //导入依赖的package包/类
@Override
protected void append(LoggingEvent event) {
if (!isAsSevereAsThreshold(event.getLevel())) {
return;
}
if (_syslogAppenders != null && !_syslogAppenders.isEmpty()) {
try {
String logMessage = event.getRenderedMessage();
if (logMessage.contains("alertType") && logMessage.contains("message")) {
parseMessage(logMessage);
String syslogMessage = createSyslogMessage();
LoggingEvent syslogEvent = new LoggingEvent(event.getFQNOfLoggerClass(), event.getLogger(), event.getLevel(), syslogMessage, null);
for (SyslogAppender syslogAppender : _syslogAppenders) {
syslogAppender.append(syslogEvent);
}
}
} catch (Exception e) {
errorHandler.error(e.getMessage());
}
}
}
示例2: setSyslogAppenders
import org.apache.log4j.net.SyslogAppender; //导入依赖的package包/类
void setSyslogAppenders() {
if (_syslogAppenders == null) {
_syslogAppenders = new ArrayList<SyslogAppender>();
}
if (_syslogHosts == null || _syslogHosts.trim().isEmpty()) {
reset();
return;
}
_syslogHostsList = parseSyslogHosts(_syslogHosts);
if (!validateIpAddresses()) {
reset();
errorHandler.error(" Invalid format for the IP Addresses parameter ");
return;
}
for (String syslogHost : _syslogHostsList) {
_syslogAppenders.add(new SyslogAppender(getLayout(), syslogHost, SyslogAppender.getFacility(_facility)));
}
}
示例3: setFacility
import org.apache.log4j.net.SyslogAppender; //导入依赖的package包/类
public void setFacility(String facility) {
if (facility == null) {
return;
}
_facility = facility;
if (_syslogAppenders != null && !_syslogAppenders.isEmpty()) {
for (SyslogAppender syslogAppender : _syslogAppenders) {
syslogAppender.setFacility(facility);
}
}
}
示例4: close
import org.apache.log4j.net.SyslogAppender; //导入依赖的package包/类
@Override
synchronized public void close() {
for (SyslogAppender syslogAppender : _syslogAppenders) {
syslogAppender.close();
}
}