Package org.egothor.methodatlas
Class JsonLineFormatter
java.lang.Object
java.util.logging.Formatter
org.egothor.methodatlas.JsonLineFormatter
Formatter that emits one JSON object per log
record, on a single line, suitable for ingestion by log-aggregation
pipelines (Elastic, Splunk, Loki) and for reproducible audit-trail
archives.
Acts as the JUL-native equivalent of an SLF4J / Logback JSON encoder.
The MethodAtlas codebase stays on the classic java.util.logging
stack (no SLF4J / Log4j dependency) per project convention; this
formatter delivers structured-logging semantics without adding any
third-party logging library.
Output schema
Each LogRecord becomes one line of UTF-8 text containing a JSON
object with the following fields:
timestamp— ISO-8601 instant (2026-05-27T13:45:06Z)level— JUL level name (INFO,WARNING, …)logger— full logger name fromLogRecord.getLoggerName()thread— name of the thread that emitted the recordmessage— the formatted log message (with parameters interpolated)runId— short correlation id fromScanRunContext, omitted when no run is set on the current threadthrown— string-rendered exception stack trace, present only whenLogRecord.getThrown()is non-null
Activation
The formatter is not installed automatically. Activate it through a JUL
configuration file (commonly via the -Djava.util.logging.config.file
system property), or programmatically by attaching the formatter to a
Handler:
Handler handler = new ConsoleHandler();
handler.setFormatter(new JsonLineFormatter());
Logger.getLogger("org.egothor.methodatlas").addHandler(handler);
Thread safety
The formatter is stateless and safe for concurrent use by multiple handlers and threads.
- Since:
- 1.0.0
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Methods inherited from class java.util.logging.Formatter
formatMessage, getHead, getTail
-
Constructor Details
-
JsonLineFormatter
public JsonLineFormatter()Creates a new formatter. The class carries no instance state and is safe to share across handlers.
-
-
Method Details