osiegmar / logback-gelf

Logback appender for sending GELF messages with zero additional dependencies.
GNU Lesser General Public License v2.1
213 stars 58 forks source link

Markers are sent with Brackets. Like "[MARKER_NAME]" instead of "MARKER_NAME" without brackets #105

Open rafael-brier opened 1 month ago

rafael-brier commented 1 month ago

Describe the bug https://github.com/osiegmar/logback-gelf/blob/v6.0.1/src/main/java/de/siegmar/logbackgelf/mappers/MarkerFieldMapper.java The bug is in the following Mapper, it is calling "toString" on "ArrayList", instead, it should call toString() for each Marker and custom join.

If the markerList has a single element or multiElements, it will be send like this: "[marker1,marker2,marker3]"

The bug was introduced in this commit: https://github.com/osiegmar/logback-gelf/commit/8e5eb634d53c71ce273945a9caeef124c84771be

Additional context Version used -> anyone after the commit

osiegmar commented 1 month ago

This change was intentionally made in version 5.0.0 to reveal the nesting of markers.

The test case of the referred commit https://github.com/osiegmar/logback-gelf/commit/8e5eb634d53c71ce273945a9caeef124c84771be shows the following change:

-assertEquals("FIRST, SECOND, THIRD", jsonNode.get("_marker").textValue());
+assertEquals("[FIRST [ SECOND ], THIRD]", jsonNode.get("_marker").textValue());

Where SECOND is nested inside FIRST and THIRD is not nested.

If you want to revert to the old behavior, you need to implement a custom field mapper as shown in https://github.com/osiegmar/logback-gelf/discussions/87.

What downsides have you experienced with the new format?