Configuration with JSON
Klogging can be configured from JSON files. This example is exactly equivalent to the first DSL example:
An earlier version used the key
dispatchTo instead of
sendTo. Use of
dispatchTo is deprecated;
a warning will be printed to the console if it is found in JSON configuration.
Configuration object names
Equivalent to the sinks DSL function. Object keyed by sink name with keys:
renderWith: name of a built-in renderer. Current values are
sendTo: name of a built-in sender. Current values are
seqServer: URL of a Seq server where events are to be dispatched. By default, the RENDER_CLEF renderer is used.
splunkServer: connection details for a Splunk server:
hecUrl: URL of the Splunk server’s HEC endpoint (HTTPS by default).
hecToken: the HEC token used by Splunk for these logging events. It is a secret that should be passed in via an environment variable.
indexis the Splunk index for the events set up by a Splunk administrator (default
sourceTypeis the Splunk
checkCertificateindicates whether Klogging should check the TLS certificate used by the Splunk server (string: default
An example of a Splunk sink called
You should have only one of
sendTo in a sink. If
you have more than one,
splunkServer takes precedence over
seqServer, which takes
sinks object is evolving and there will be more options in the future.
Equivalent to the logging DSL function. Array of objects, each with optional keys:
fromLoggerBase: base name to match logger names.
exactLogger: exact name of logger to match.
matchLogger: a Kotlin regular expression pattern used to match logger names.
You should specify only one of these in a
logging object. If more are specified,
matchLogger takes precedence over
exactLogger, which takes precedence over
If you specify no key, all loggers will match. This configuration is the equivalent of the root logger in Log4j or Logback.
Array of objects, each with keys:
fromMinLevel: Name of the minimum level for log events to be emitted. For example, if the value is
INFOthen events at severity
FATALwill be emitted. Equivalent to the fromMinLevel DSL function.
atLevel: Name of the exact level at which log events will be emitted. Equivalent to the atLevel DSL function.
toSinks: Array of sink names where events will be sent. If it does not match a key of the
sinksobject, a warning is written to the console and the configuration is ignored.
You must specify at least one
levelRange object with at least one matching sink name or no logs will be