ch.qos.logback.classic.util.LevelToSyslogSeverity Java Examples

The following examples show how to use ch.qos.logback.classic.util.LevelToSyslogSeverity. 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: GelfEncoder.java    From logback-gelf with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public byte[] encode(final ILoggingEvent event) {
    final String shortMessage = shortPatternLayout.doLayout(event);
    final String fullMessage = fullPatternLayout.doLayout(event);
    final Map<String, Object> additionalFields = mapAdditionalFields(event);

    final GelfMessage gelfMessage = new GelfMessage(originHost, shortMessage, fullMessage,
        event.getTimeStamp(), LevelToSyslogSeverity.convert(event), additionalFields);

    String jsonStr = gelfMessageToJson(gelfMessage);
    if (appendNewline) {
        jsonStr += System.lineSeparator();
    }

    return jsonStr.getBytes(StandardCharsets.UTF_8);
}
 
Example #2
Source File: Syslog4jAppender.java    From logback-syslog4j with MIT License 5 votes vote down vote up
/**
 * Convert a level to equivalent syslog severity. Only levels for printing
 * methods i.e DEBUG, WARN, INFO and ERROR are converted.
 *
 * @see ch.qos.logback.core.net.SyslogAppenderBase#getSeverityForEvent(java.lang.Object)
 */
public int getSeverityForEvent(Object eventObject) {
    if (eventObject instanceof ILoggingEvent) {
        ILoggingEvent event = (ILoggingEvent) eventObject;
        return LevelToSyslogSeverity.convert(event);
    } else {
        return SyslogIF.LEVEL_INFO;
    }
}
 
Example #3
Source File: MillisecondPrecisionSyslogStartConverter.java    From logging-java with Apache License 2.0 5 votes vote down vote up
public String convert(final ILoggingEvent event) {
  final StringBuilder sb = new StringBuilder();

  final int pri = facility + LevelToSyslogSeverity.convert(event);

  sb.append("<");
  sb.append(pri);
  sb.append(">");
  sb.append(computeTimeStampString(event.getTimeStamp()));
  sb.append(' ');
  sb.append(localHostName);
  sb.append(' ');

  return sb.toString();
}