Event Logger

EventLogger is a convenience to log StructuredDataMessages, which format their content in a way compliant with the Syslog message format described in RFC 5424. Historically, EventLogger was added to help users migrate from SLF4J EventLogger, which was removed in SLF4J version 1.7.26.

Event Logger is deprecated for removal! We advise users to switch to plain Logger instead. Refer to Log4j API on how to use Logger.

Compared to using a plain Logger, EventLogger

  • attaches an EVENT marker, and

  • sets the level to OFF, unless one is explicitly provided.

That is, following EventLogger usages:

EventLogger.logEvent(new StructuredDataMessage(...));
EventLogger.logEvent(new StructuredDataMessage(...), Level.INFO);

are equivalent to the following plain Logger usages:

private static final Marker EVENT_MARKER = MarkerManager.getMarker("EVENT");
private static final Logger LOGGER = LogManager.getLogger();

LOGGER.log(Level.OFF, EVENT_MARKER, new StructuredDataMessage(...));
LOGGER.info(EVENT_MARKER, new StructuredDataMessage(...));