Package-level declarations
Types
Base exception class to allow you to attach log fields to exceptions. When passing a cause
exception to one of the methods on Logger, it will check if the given exception is an instance of this class, and if it is, these fields will be added to the log.
Interface to allow you to attach log fields to exceptions. When passing a cause
exception to one of the methods on Logger, it will check if the given exception implements this interface, and if it does, these fields will be added to the log.
Class used in the logging methods on Logger, allowing you to add structured key-value data to the log by calling the field and rawJsonField methods.
A logger provides methods for logging at various log levels (info, warn, error, debug and trace). It has a logger name, typically the same as the class that the logger is attached to (e.g. com.example.Example
). The name is included in the log output, and can be used to enable/disable log levels for loggers based on their package names, or query for logs from a specific class.
Writes logging context fields as JSON when using logstash-logback-encoder
. We need this in order to include object fields as raw JSON instead of escaped strings on the log output.
Functions
Returns a copy of the log fields in the current thread's logging context (from withLoggingContext). This can be used to pass logging context between threads (see example below).
Wraps an ExecutorService in a new implementation that copies logging context fields (from withLoggingContext) from the parent thread to child threads when spawning new tasks. This is useful when you use an ExecutorService
in the scope of a logging context, and you want the fields from the logging context to also be included on the logs in the child tasks.
Turns the given pre-serialized JSON string into a JsonElement (from kotlinx.serialization
), using the same validation logic as rawJsonField.
Adds the given log fields to every log made by a Logger in the context of the given block. Use the field/rawJsonField functions to construct log fields.