LogFormatters

Factory object for obtaining standard LogEventFormatter implementations.

Each factory method returns a pre-configured formatter suitable for common output scenarios. Custom formatters can be created by implementing LogEventFormatter directly or using its fun interface syntax:

val myFormatter = LogEventFormatter { event ->
"[${event.level}] ${event.loggerName}: ${event.message}"
}

Functions

Link copied to clipboard

Returns a formatter that produces a compact single-line output including the log level, logger name, message, and inline attributes.

Link copied to clipboard

Returns a formatter that produces a concise, human-readable single-line output containing the log level, logger name, message, and stack trace (if a throwable is present).

Link copied to clipboard
fun json(showEmoji: Boolean): LogEventFormatter

Returns a formatter that serializes each log event as a single-line JSON object, suitable for ingestion by log aggregation platforms such as Elasticsearch, Datadog, Splunk, and Loki.

Link copied to clipboard
fun pretty(showEmoji: Boolean, includeTimestamp: Boolean = false, includeThread: Boolean = false, prettyPrint: Boolean = true): LogEventFormatter

Returns a formatter that produces a detailed, human-readable output with optional timestamp, thread name, and pretty-printed attributes and context.