Java Code Examples for ch.qos.logback.classic.spi.ILoggingEvent#getThrowableProxy()

The following examples show how to use ch.qos.logback.classic.spi.ILoggingEvent#getThrowableProxy() . 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: ILoggingEventSerializer.java    From twill with Apache License 2.0 6 votes vote down vote up
@Override
public JsonElement serialize(ILoggingEvent event, Type typeOfSrc, JsonSerializationContext context) {
  JsonObject json = new JsonObject();
  json.addProperty("name", event.getLoggerName());
  json.addProperty("host", hostname);
  json.addProperty("timestamp", Long.toString(event.getTimeStamp()));
  json.addProperty("level", event.getLevel().toString());
  json.addProperty("className", classNameConverter.convert(event));
  json.addProperty("method", methodConverter.convert(event));
  json.addProperty("file", fileConverter.convert(event));
  json.addProperty("line", lineConverter.convert(event));
  json.addProperty("thread", event.getThreadName());
  json.addProperty("message", event.getFormattedMessage());
  json.addProperty("runnableName", runnableName);
  if (event.getThrowableProxy() == null) {
    json.add("throwable", JsonNull.INSTANCE);
  } else {
    json.add("throwable", context.serialize(new DefaultLogThrowable(event.getThrowableProxy()), LogThrowable.class));
  }

  return json;
}
 
Example 2
Source File: DingTalkAppender.java    From jframework with Apache License 2.0 6 votes vote down vote up
private String transformStackTrace(ILoggingEvent event) {
    String exception = "";
    IThrowableProxy throwableProxy =  event.getThrowableProxy();
    if (throwableProxy != null) {
        exception = ThrowableProxyUtil.asString(throwableProxy);
    }

    StackTraceElement[] callerData = event.getCallerData();
    StackTraceElement stackTraceElement = callerData[0];

    String time = DEFAULT_DATE_FORMAT.format(new Date(event.getTimeStamp()));
    String threadName = event.getThreadName();
    String level = event.getLevel().toString();
    String logger = event.getLoggerName();
    String msg = event.getFormattedMessage();
    String className = stackTraceElement.getClassName();
    String method = stackTraceElement.getMethodName();
    int lineNumber = stackTraceElement.getLineNumber();

    return String.format(FORMAT_MESSAGE, time, threadName, level, logger, className, method, lineNumber, exception, msg);
}
 
Example 3
Source File: Gateway.java    From arcusplatform with Apache License 2.0 6 votes vote down vote up
@Override
public void appendLogEntry(ILoggingEvent event) {
   JsonObject object = new JsonObject();
   for(Map.Entry<String, String> e: event.getMDCPropertyMap().entrySet()) {
      object.addProperty(e.getKey(), e.getValue());
   }

   object.addProperty("ts", event.getTimeStamp());
   object.addProperty("lvl", event.getLevel().toString());
   object.addProperty("thd", event.getThreadName());
   object.addProperty("log", event.getLoggerName());
   object.addProperty("msg", event.getFormattedMessage());

   IThrowableProxy thrw = event.getThrowableProxy();
   if (thrw != null) {
      String stackTrace = converter.convert(event);
      object.addProperty("exc", stackTrace);
   } else {
      object.remove("exc");
   }

   if (!bufferedLogMessages.offer(object)) {
      log.trace("log message dropped because queue overflowed");
   }
}
 
Example 4
Source File: LogFilter.java    From DimpleBlog with Apache License 2.0 6 votes vote down vote up
@Override
public FilterReply decide(ILoggingEvent event) {
    StringBuilder exception = new StringBuilder();
    IThrowableProxy iThrowableProxy1 = event.getThrowableProxy();
    if (iThrowableProxy1 != null) {
        exception.append("<span class='excehtext'>" + iThrowableProxy1.getClassName() + " " + iThrowableProxy1.getMessage() + "</span></br>");
        for (int i = 0; i < iThrowableProxy1.getStackTraceElementProxyArray().length; i++) {
            exception.append("<span class='excetext'>" + iThrowableProxy1.getStackTraceElementProxyArray()[i].toString() + "</span></br>");
        }
    }
    LoggerMessage loggerMessage = new LoggerMessage(
            event.getMessage()
            , DateFormat.getDateTimeInstance().format(new Date(event.getTimeStamp())),
            event.getThreadName(),
            event.getLoggerName(),
            event.getLevel().levelStr,
            exception.toString(),
            ""
    );
    LoggerQueue.getInstance().push(loggerMessage);
    return FilterReply.ACCEPT;
}
 
Example 5
Source File: LoggingFilter.java    From NationStatesPlusPlus with MIT License 6 votes vote down vote up
@Override
public FilterReply decide(ILoggingEvent event) {
	final IThrowableProxy throwableProxy = event.getThrowableProxy();
	if (throwableProxy == null) {
		return FilterReply.NEUTRAL;
	}

	if (!(throwableProxy instanceof ThrowableProxy)) {
		return FilterReply.NEUTRAL;
	}

	final ThrowableProxy throwableProxyImpl = (ThrowableProxy) throwableProxy;
	final Throwable throwable = throwableProxyImpl.getThrowable();
	if (java.nio.channels.ClosedChannelException.class.isInstance(throwable)) {
		return FilterReply.DENY;
	}

	return FilterReply.NEUTRAL;
}
 
Example 6
Source File: LogbackLoggingConfigurer.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
protected void append(ILoggingEvent event) {
    try {
        ThrowableProxy throwableProxy = (ThrowableProxy) event.getThrowableProxy();
        Throwable throwable = throwableProxy == null ? null : throwableProxy.getThrowable();
        String message = event.getFormattedMessage();
        LogLevel level = LogLevelConverter.toGradleLogLevel(event.getLevel(), event.getMarker());
        outputEventListener.onOutput(new LogEvent(event.getTimeStamp(), event.getLoggerName(), level, message, throwable));
    } catch (Throwable t) {
        // fall back to standard out
        t.printStackTrace(defaultStandardOut);
    }
}
 
Example 7
Source File: CloudwatchLogsLogbackAppender.java    From cloudwatchlogs-java-appender with Apache License 2.0 5 votes vote down vote up
@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 8
Source File: Logback1027WorkaroundTurboFilterTest.java    From qpid-broker-j with Apache License 2.0 5 votes vote down vote up
private void assertLoggingEvent(final ILoggingEvent loggingEvent)
{
    assertEquals(Level.INFO, loggingEvent.getLevel());
    assertEquals(TEST_LOG_MESSAGE, loggingEvent.getMessage());
    assertNull(loggingEvent.getArgumentArray());
    IThrowableProxy thing = loggingEvent.getThrowableProxy();
    assertEquals(Logback1027WorkaroundTurboFilter.StringifiedException.class.getName(), thing.getClassName());
}
 
Example 9
Source File: LogbackStacktraceConverter.java    From cf-java-logging-support with Apache License 2.0 5 votes vote down vote up
@Override
public String convert(ILoggingEvent event) {
    StringBuilder appendTo = new StringBuilder();
    IThrowableProxy tProxy = event.getThrowableProxy();
    if (tProxy != null && ThrowableProxy.class.isAssignableFrom(tProxy.getClass())) {
        StacktraceConverter.CONVERTER.convert(((ThrowableProxy) tProxy).getThrowable(), appendTo);
        return appendTo.toString();
    }
    return null;
}
 
Example 10
Source File: LogWatcher.java    From brooklyn-server with Apache License 2.0 5 votes vote down vote up
public void printEvents(PrintStream stream, Iterable<? extends ILoggingEvent> events) {
    for (ILoggingEvent event : events) {
        stream.println(Time.makeDateString(event.getTimeStamp()) + ": " + event.getThreadName()
                + ": " + event.getLevel() + ": " + event.getMessage());
        IThrowableProxy throwable = event.getThrowableProxy();
        if (throwable != null) {
            stream.println("\t" + throwable.getMessage());
            if (throwable.getStackTraceElementProxyArray() != null) {
                for (StackTraceElementProxy element : throwable.getStackTraceElementProxyArray()) {
                    stream.println("\t\t" + "at " + element);
                }
            }
        }
    }
}
 
Example 11
Source File: UKeFuAppender.java    From youkefu with Apache License 2.0 5 votes vote down vote up
@Override
public void append(ILoggingEvent event) {
	super.append(event);
	try {
		if(UKDataContext.getContext()!=null) {
			Log log = new Log(UKDataContext.SYSTEM_ORGI , null , event.getFormattedMessage() , event.getLevel().toString() , event.getThreadName());
			log.setClazz(event.getLoggerName()) ;
			if(event.getFormattedMessage()!=null && event.getFormattedMessage().length() < 255){
				log.setMemo(event.getFormattedMessage());
			}else{
				log.setMemo(event.getFormattedMessage().substring(0 ,255));
			}
			if(event.getThrowableProxy()!=null){
				log.setMsg(ThrowableProxyUtil.asString(event.getThrowableProxy()));
			}
			
			log.setMethod(event.getThreadName());
			log.setLogtype(event.getLevel().toString().equals(Level.ERROR.toString()) ? "1" : "0") ;
			log.setLogtime(String.valueOf(UKTools.dateFormate.format(new Date()))) ;
			/**
			 * 临时缓存
			 */
			UKDataContext.tempLogQueue.add(log) ;
		}
	} catch (Throwable sqle) {
		sqle.printStackTrace();
	}

}
 
Example 12
Source File: StructuredLoggingEncoder.java    From flo with Apache License 2.0 5 votes vote down vote up
private byte[] encodeText(ILoggingEvent event) {
  final TaskId taskId = taskId();
  final String taskIdString = (taskId != null) ? taskId.toString() : "";
  final StringBuilder sb = new StringBuilder();
  final Formatter formatter = new Formatter(sb);
  formatter.format("%s %-5s [%s] %s: %s%n",
      Instant.ofEpochMilli(event.getTimeStamp()).toString(),
      event.getLevel(), taskIdString, loggerName(event), event.getFormattedMessage());
  final IThrowableProxy t = event.getThrowableProxy();
  if (t != null) {
    writeStack(sb, t, "", 0, LINE_SEPARATOR);
  }
  return sb.toString().getBytes(UTF_8);
}
 
Example 13
Source File: BugsnagAppender.java    From bugsnag-java with MIT License 5 votes vote down vote up
/**
 * Gets the throwable from the log event (if any)
 * @param event The log event
 * @return The throwable (or null)
 */
private Throwable extractThrowable(ILoggingEvent event) {
    IThrowableProxy throwableProxy = event.getThrowableProxy();
    if (throwableProxy instanceof ThrowableProxy) {
        return ((ThrowableProxy) throwableProxy).getThrowable();
    }

    return null;
}
 
Example 14
Source File: IrisLayout.java    From arcusplatform with Apache License 2.0 5 votes vote down vote up
@Override
public String doLayout(@Nullable ILoggingEvent event) {
   if (event == null) {
      return "";
   }

   for(Map.Entry<String, String> e: event.getMDCPropertyMap().entrySet()) {
      object.addProperty(e.getKey(), e.getValue());
   }

   object.addProperty("ts", event.getTimeStamp());
   object.addProperty("lvl", event.getLevel().toString());
   object.addProperty("thd", event.getThreadName());
   object.addProperty("log", event.getLoggerName());
   object.addProperty("msg", event.getFormattedMessage());
   object.addProperty("svc", "agent");

   String hubId = IrisHal.getHubIdOrNull();
   if (hubId != null) {
      object.addProperty("hst", hubId);
   }

   String hubVersion = IrisHal.getOperatingSystemVersionOrNull();
   if (hubVersion != null) {
      object.addProperty("svr", hubVersion);
   }

   IThrowableProxy thrw = event.getThrowableProxy();
   if (thrw != null) {
      String stackTrace = converter.convert(event);
      object.addProperty("exc", stackTrace);
   } else {
      object.remove("exc");
   }

   return IrisAgentSotConverter.SOT + GSON.toJson(object);
}
 
Example 15
Source File: IrisLayout.java    From arcusplatform with Apache License 2.0 5 votes vote down vote up
@Override
public String doLayout(ILoggingEvent event) {
   if (!isJson) {
      return super.doLayout(event);
   }

   JsonObject object = new JsonObject();
   for(Map.Entry<String, String> e: event.getMDCPropertyMap().entrySet()) {
      object.addProperty(e.getKey(), e.getValue());
   }

   object.addProperty("ts", event.getTimeStamp());
   object.addProperty("sev", event.getLevel().toString());
   object.addProperty("host", IrisApplicationInfo.getHostName());
   if (IrisApplicationInfo.getContainerName() != null) {
      object.addProperty("ctn", IrisApplicationInfo.getContainerName());
   }
   object.addProperty("svc", IrisApplicationInfo.getApplicationName());
   object.addProperty("svr", IrisApplicationInfo.getApplicationVersion());
   object.addProperty("thd", event.getThreadName());
   object.addProperty("log", event.getLoggerName());
   object.addProperty("msg", event.getFormattedMessage());

   IThrowableProxy thrw = event.getThrowableProxy();
   if (thrw != null) {
      String stackTrace = converter.convert(event);
      object.addProperty("exc", stackTrace);
   } else {
      object.remove("exc");
   }

   String json = GSON.toJson(object);
   if (isJsonString) {
      json = GSON.toJson(json);
   }

   return json + "\n";
}
 
Example 16
Source File: EcsEncoder.java    From ecs-logging-java with Apache License 2.0 5 votes vote down vote up
@Override
public byte[] encode(ILoggingEvent event) {
    StringBuilder builder = new StringBuilder();
    EcsJsonSerializer.serializeObjectStart(builder, event.getTimeStamp());
    EcsJsonSerializer.serializeLogLevel(builder, event.getLevel().toString());
    EcsJsonSerializer.serializeFormattedMessage(builder, event.getFormattedMessage());
    serializeMarkers(event, builder);
    EcsJsonSerializer.serializeServiceName(builder, serviceName);
    EcsJsonSerializer.serializeEventDataset(builder, eventDataset);
    EcsJsonSerializer.serializeThreadName(builder, event.getThreadName());
    EcsJsonSerializer.serializeLoggerName(builder, event.getLoggerName());
    serializeAdditionalFields(builder);
    EcsJsonSerializer.serializeMDC(builder, event.getMDCPropertyMap());
    if (includeOrigin) {
        StackTraceElement[] callerData = event.getCallerData();
        if (callerData != null && callerData.length > 0) {
            EcsJsonSerializer.serializeOrigin(builder, callerData[0]);
        }
    }
    IThrowableProxy throwableProxy = event.getThrowableProxy();
    if (throwableProxy instanceof ThrowableProxy) {
        EcsJsonSerializer.serializeException(builder, ((ThrowableProxy) throwableProxy).getThrowable(), stackTraceAsArray);
    } else if (throwableProxy != null) {
        EcsJsonSerializer.serializeException(builder, throwableProxy.getClassName(), throwableProxy.getMessage(), throwableProxyConverter.convert(event), stackTraceAsArray);
    }
    EcsJsonSerializer.serializeObjectEnd(builder);
    // all these allocations kinda hurt
    return builder.toString().getBytes(UTF_8);
}
 
Example 17
Source File: JSONEventLayout.java    From logback-redis-appender with Apache License 2.0 4 votes vote down vote up
/**
 * Formats a {@link ILoggingEvent} in conformity with the log4j.dtd.
 */
public synchronized String doLayout(ILoggingEvent event) {

	// Reset working buffer. If the buffer is too large, then we need a new
	// one in order to avoid the penalty of creating a large array.
	if (buf.capacity() > UPPER_LIMIT) {
		buf = new StringBuilder(DEFAULT_SIZE);
	} else {
		buf.setLength(0);
	}

	Map<String, String> mdc = event.getMDCPropertyMap();
	buf.append("{");
	appendKeyValue(buf, "source", source, mdc);
	buf.append(COMMA);
	appendKeyValue(buf, "host", sourceHost, mdc);
	buf.append(COMMA);
	appendKeyValue(buf, "path", sourcePath, mdc);
	buf.append(COMMA);
	appendKeyValue(buf, "type", type, mdc);
	buf.append(COMMA);
	appendKeyValue(buf, "tags", tags, mdc);
	buf.append(COMMA);
	appendKeyValue(buf, "message", event.getFormattedMessage(), null);
	buf.append(COMMA);
	appendKeyValue(buf, "@timestamp",
			df.format(new Date(event.getTimeStamp())), null);
	buf.append(COMMA);

	// ---- fields ----
	appendKeyValue(buf, "logger", event.getLoggerName(), null);
	buf.append(COMMA);
	appendKeyValue(buf, "level", event.getLevel().toString(), null);
	buf.append(COMMA);
	appendKeyValue(buf, "thread", event.getThreadName(), null);
	IThrowableProxy tp = event.getThrowableProxy();
	if (tp != null) {
		buf.append(COMMA);
		String throwable = ThrowableProxyUtil.asString(tp);
		appendKeyValue(buf, "throwable", throwable, null);
	}
	if (locationInfo) {
		StackTraceElement[] callerDataArray = event.getCallerData();
		if (callerDataArray != null
				&& callerDataArray.length > callerStackIdx) {
			buf.append(COMMA);
			buf.append("\"location\":{");
			StackTraceElement immediateCallerData = callerDataArray[callerStackIdx];
			appendKeyValue(buf, "class",
					immediateCallerData.getClassName(), null);
			buf.append(COMMA);
			appendKeyValue(buf, "method",
					immediateCallerData.getMethodName(), null);
			buf.append(COMMA);
			appendKeyValue(buf, "file", immediateCallerData.getFileName(),
					null);
			buf.append(COMMA);
			appendKeyValue(buf, "line",
					Integer.toString(immediateCallerData.getLineNumber()),
					null);
			buf.append("}");
		}
	}

	/*
	 * <log4j:properties> <log4j:data name="name" value="value"/>
	 * </log4j:properties>
	 */
	if (properties) {
		Map<String, String> propertyMap = event.getMDCPropertyMap();
		if ((propertyMap != null) && (propertyMap.size() != 0)) {
			Set<Entry<String, String>> entrySet = propertyMap.entrySet();
			buf.append(COMMA);
			buf.append("\"properties\":{");
			Iterator<Entry<String, String>> i = entrySet.iterator();
			while (i.hasNext()) {
				Entry<String, String> entry = i.next();
				appendKeyValue(buf, entry.getKey(), entry.getValue(), null);
				if (i.hasNext()) {
					buf.append(COMMA);
				}
			}
			buf.append("}");
		}
	}

	if(additionalFields != null) {
		for(AdditionalField field : additionalFields) {
			buf.append(COMMA);
			appendKeyValue(buf, field.getKey(), field.getValue(), mdc);
		}
	}

	buf.append("}");

	return buf.toString();
}
 
Example 18
Source File: LogbackVerifier.java    From java-sdk with Apache License 2.0 4 votes vote down vote up
private boolean matchThrowables(ILoggingEvent actual) {
    IThrowableProxy eventProxy = actual.getThrowableProxy();
    return throwableClass == null || eventProxy != null && throwableClass.getName().equals(eventProxy.getClassName());
}
 
Example 19
Source File: GelfAppender.java    From logback-gelf-appender with Apache License 2.0 4 votes vote down vote up
@Override
protected void append(ILoggingEvent event) {

    if (event == null) {
        return;
    }

    // create a copy of the logging event to avoid passing exception stacktraces to GELF's short_message field
    LoggingEvent copy = new LoggingEvent();
    copy.setMessage(event.getMessage());
    copy.setLevel(event.getLevel());
    copy.setArgumentArray(event.getArgumentArray());
    copy.setLoggerName(event.getLoggerName());
    copy.setThreadName(event.getThreadName());
    copy.setTimeStamp(event.getTimeStamp());
    copy.setMDCPropertyMap(event.getMDCPropertyMap());

    final GelfMessageBuilder builder = new GelfMessageBuilder(this.layout.doLayout(copy), hostName).timestamp(
                event.getTimeStamp() / 1000d)
            .level(GelfMessageLevel.fromNumericLevel(toGelfNumericValue(event.getLevel())))
            .additionalField("loggerName", event.getLoggerName())
            .additionalField("threadName", event.getThreadName());

    final Marker marker = event.getMarker();

    if (marker != null) {
        builder.additionalField("marker", marker.getName());
    }

    if (includeMDC) {
        for (Map.Entry<String, String> entry : event.getMDCPropertyMap().entrySet()) {
            builder.additionalField(entry.getKey(), entry.getValue());
        }
    }

    final StackTraceElement[] callerData = event.getCallerData();

    if (includeSource && event.hasCallerData() && callerData.length > 0) {
        StackTraceElement source = callerData[0];

        builder.additionalField("sourceFileName", source.getFileName());
        builder.additionalField("sourceMethodName", source.getMethodName());
        builder.additionalField("sourceClassName", source.getClassName());
        builder.additionalField("sourceLineNumber", source.getLineNumber());
    }

    final IThrowableProxy thrown = event.getThrowableProxy();

    if (includeStackTrace && thrown != null) {
        String convertedThrowable = throwableConverter.convert(event);

        builder.additionalField("exceptionClass", thrown.getClassName());
        builder.additionalField("exceptionMessage", thrown.getMessage());
        builder.additionalField("exceptionStackTrace", convertedThrowable);

        builder.fullMessage(event.getFormattedMessage() + "\n\n" + convertedThrowable);
    } else {
        builder.fullMessage(event.getFormattedMessage());
    }

    if (includeLevelName) {
        builder.additionalField("levelName", event.getLevel().levelStr);
    }

    if (!additionalFields.isEmpty()) {
        builder.additionalFields(additionalFields);
    }

    if(!client.trySend(builder.build())) {
        addError("Failed to write log event to the GELF server using trySend");
    }
}
 
Example 20
Source File: LogzioLogbackAppender.java    From logzio-logback-appender with Apache License 2.0 4 votes vote down vote up
private JsonObject formatMessageAsJsonInternal(ILoggingEvent loggingEvent) {
    JsonObject logMessage;

    if (format.equals(FORMAT_JSON)) {
        try {
            JsonElement jsonElement = gson.fromJson(loggingEvent.getFormattedMessage(), JsonElement.class);
            logMessage = jsonElement.getAsJsonObject();
        } catch (Exception e) {
            logMessage = new JsonObject();
            logMessage.addProperty(MESSAGE, loggingEvent.getFormattedMessage());
        }
    } else {
        logMessage = new JsonObject();
        logMessage.addProperty(MESSAGE, loggingEvent.getFormattedMessage());
    }

    // Adding MDC first, as I dont want it to collide with any one of the following fields
    if (loggingEvent.getMDCPropertyMap() != null) {
        loggingEvent.getMDCPropertyMap().forEach(logMessage::addProperty);
    }

    logMessage.addProperty(TIMESTAMP, new Date(loggingEvent.getTimeStamp()).toInstant().toString());
    logMessage.addProperty(LOGLEVEL,loggingEvent.getLevel().levelStr);

    if (loggingEvent.getMarker() != null) {
        logMessage.addProperty(MARKER, loggingEvent.getMarker().toString());
    }

    logMessage.addProperty(LOGGER, loggingEvent.getLoggerName());
    logMessage.addProperty(THREAD, loggingEvent.getThreadName());
    if (line) {
        logMessage.addProperty(LINE, lineOfCallerConverter.convert(loggingEvent));
    }

    if (loggingEvent.getThrowableProxy() != null) {
        logMessage.addProperty(EXCEPTION, throwableProxyConverter.convert(loggingEvent));
    }

    if (additionalFieldsMap != null) {
        additionalFieldsMap.forEach(logMessage::addProperty);
    }

    return logMessage;
}