use of org.apache.log4j.net.SyslogAppender in project cloudstack by apache.
the class AlertsSyslogAppender method append.
@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());
}
}
}
use of org.apache.log4j.net.SyslogAppender in project cloudstack by apache.
the class AlertsSyslogAppender method setSyslogAppenders.
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)));
}
}
Aggregations