LogContext
classin packageklyn.logging
public final class LogContext implements AutoClosable:
LogContext
All Implemented Interfaces: AutoClosable

Scoped structured logging context.

Context values are associated with the current Klyn thread and are merged into every event emitted inside the scope. Nested scopes inherit the outer values and explicit logger fields take final precedence.

Example
import klyn.logging

try context = Logs.context(requestId = "req-42"):
LogManager.getLogger("http").info("Request received")
Properties
Modifier and Type Member Description
public readonly property active
active as Boolean:
Whether this scope is still installed.
public readonly property fields
fields as LogFields:
Structured fields owned by this exact scope.
public readonly property spanId
spanId as String:
Span identifier associated with this scope.
public readonly property traceId
traceId as String:
Trace identifier associated with this scope.
Constructors
Modifier and Type Member Description
public LogContext
LogContext(fields as Map<String, Object> = null):
Opens a context containing the supplied fields.
Methods
Modifier and Type Member Description
public close
close() as Void:
Closes this scope.
Inherited Methods
methodInherited Methods from AutoClosable: close