Java Code Examples for ch.qos.logback.classic.spi.ILoggingEvent#getTimeStamp()
The following examples show how to use
ch.qos.logback.classic.spi.ILoggingEvent#getTimeStamp() .
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 |
@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: CloudwatchLogsLogbackAppender.java From cloudwatchlogs-java-appender with Apache License 2.0 | 5 votes |
@Override protected void append(ILoggingEvent event) { StringBuilder message = new StringBuilder(event.getFormattedMessage()); IThrowableProxy throwableProxy = event.getThrowableProxy(); while (throwableProxy != null) { message.append("\n").append(dump(throwableProxy)); throwableProxy = throwableProxy.getCause(); if (throwableProxy != null) { message.append("\nCaused by:"); } } String account = event.getMDCPropertyMap().get(CloudwatchLogsMDCPropertyNames.ACCOUNT); String action = event.getMDCPropertyMap().get(CloudwatchLogsMDCPropertyNames.ACTION); String user = event.getMDCPropertyMap().get(CloudwatchLogsMDCPropertyNames.USER); String session = event.getMDCPropertyMap().get(CloudwatchLogsMDCPropertyNames.SESSION); String request = event.getMDCPropertyMap().get(CloudwatchLogsMDCPropertyNames.REQUEST); Marker marker = event.getMarker(); String eventId = marker == null ? null : marker.getName(); Map<String, String> customMdcAttributes = new HashMap<>(); for (String key : config.getCustomMdcKeys()) { String value = event.getMDCPropertyMap().get(key); if (value != null) { customMdcAttributes.put(key, value); } } CloudwatchLogsLogEvent logEvent = new CloudwatchLogsLogEvent(event.getLevel().toString(), event.getLoggerName(), eventId, message.toString(), event.getTimeStamp(), event.getThreadName(), account, action, user, session, request, customMdcAttributes); while (!eventQueue.offer(logEvent)) { // Discard old logging messages while queue is full. eventQueue.poll(); discardedCount.incrementAndGet(); } processedCount.incrementAndGet(); }
Example 3
Source File: LogEventComparator.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
@Override public int compare(ILoggingEvent o1, ILoggingEvent o2) { // cast should be safe as MAX_INT miliseconds are ~25 days return (int) (o1.getTimeStamp() - o2.getTimeStamp()); }