@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());
}
}
}
java类org.apache.log4j.net.SyslogAppender的实例源码
AlertsSyslogAppender.java 文件源码
项目:cloudstack
阅读 23
收藏 0
点赞 0
评论 0
AlertsSyslogAppender.java 文件源码
项目:cloudstack
阅读 30
收藏 0
点赞 0
评论 0
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)));
}
}
AlertsSyslogAppender.java 文件源码
项目:cloudstack
阅读 25
收藏 0
点赞 0
评论 0
public void setFacility(String facility) {
if (facility == null) {
return;
}
_facility = facility;
if (_syslogAppenders != null && !_syslogAppenders.isEmpty()) {
for (SyslogAppender syslogAppender : _syslogAppenders) {
syslogAppender.setFacility(facility);
}
}
}
AlertsSyslogAppender.java 文件源码
项目:cloudstack
阅读 25
收藏 0
点赞 0
评论 0
@Override
synchronized public void close() {
for (SyslogAppender syslogAppender : _syslogAppenders) {
syslogAppender.close();
}
}