Package io.github.merlimat.slog.handler
Class Log4j2Handler
java.lang.Object
io.github.merlimat.slog.handler.Log4j2Handler
- All Implemented Interfaces:
Handler
Handler implementation that delegates to Log4j2.
Structured attributes are placed into the Log4j2 ThreadContext
for the duration of each log call. When using JsonLayout with
properties="true", each attribute appears as an individual field
inside the contextMap JSON object.
This handler is selected automatically when org.apache.logging.log4j.LogManager
is present on the classpath.
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Log4j2Handler
public Log4j2Handler()Creates a new Log4j2 handler.
-
-
Method Details
-
isEnabled
Description copied from interface:HandlerChecks whether logging is enabled for the given logger name and level.This is called before any event construction, ensuring zero overhead when the level is disabled.
-
handle
Description copied from interface:HandlerProcesses a structured log record, emitting it to the underlying logging framework.
-