/** * Creates a map of properties that represent the GELF message. * * @param logEvent The log event * @return map of gelf properties */ private Map<String, Object> mapFields(ILoggingEvent logEvent) { Map<String, Object> map = new HashMap<String, Object>(); map.put("facility", facility); map.put("host", hostname); String message = patternLayout.doLayout(logEvent); map.put("full_message", message); map.put("short_message", truncateToShortMessage(message, logEvent)); // Ever since version 0.9.6, GELF accepts timestamps in decimal form. double logEventTimeTimeStamp = logEvent.getTimeStamp() / 1000.0; stackTraceField(map, logEvent); map.put("timestamp", logEventTimeTimeStamp); map.put("version", "1.0"); map.put("level", LevelToSyslogSeverity.convert(logEvent)); additionalFields(map, logEvent); staticAdditionalFields(map); return map; }
public String convert(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(); }