Java Code Examples for org.apache.log4j.spi.LoggingEvent#getFQNOfLoggerClass()

The following examples show how to use org.apache.log4j.spi.LoggingEvent#getFQNOfLoggerClass() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AlertsSyslogAppender.java    From cloudstack with Apache License 2.0 6 votes vote down vote up
@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());
        }
    }
}
 
Example 2
Source File: Log4JAppenderWrapper.java    From mrgeo with Apache License 2.0 5 votes vote down vote up
@Override
public void doAppend(LoggingEvent event)
{
  assert (wrappedAppender != null);


  String msg = event.getMessage().toString();

  Matcher m = crlf.matcher(msg);
  if (m.find())
  {
    String lines[] = msg.split("\r\n|\n|\r"); //msg.split("\\r?\\n");

    for (String line : lines)
    {
      String clean = "(Encoded) " + line;

      LoggingEvent encoded = new LoggingEvent(event.getFQNOfLoggerClass(),
          event.getLogger(), event.getTimeStamp(), event.getLevel(), clean,
          event.getThreadName(), event.getThrowableInformation(), event.getNDC(),
          event.getLocationInformation(), event.getProperties());

      wrappedAppender.doAppend(encoded);
    }
  }
  else
  {
    wrappedAppender.doAppend(event);
  }

}
 
Example 3
Source File: StreamAppender.java    From samza with Apache License 2.0 4 votes vote down vote up
private LoggingEvent subLog(LoggingEvent event) {
  return new LoggingEvent(event.getFQNOfLoggerClass(), event.getLogger(), event.getTimeStamp(),
      event.getLevel(), subAppend(event), event.getThreadName(), event.getThrowableInformation(),
      event.getNDC(), event.getLocationInformation(), event.getProperties());
}