Configuration
Klogging starts with no configuration and will not send any log events. You configure Klogging using either:
- in code using the Configuration domain-specific language
- using from a JSON or HOCON configuration file.
You can also override some configuration by setting Environment variables.
Configuration structure
Klogging configuration has this structure:
- Declare one or more sinks where log events are sent.
- Declare logging, to specify how log events are dispatched to sinks.
How Klogging loads configuration
Klogging first searches for file-based configuration, when it is first needed. The patterns are:
Source | Configuration |
---|---|
File only | Read from file when the first logger is declared. |
DSL only | Set when the DSL code is executed. |
File and DSL | Read from file immediately before the DSL code is read. DSL configuration replaces file configuration unless it begins with loggingConfiguration(append = true) . |
How Klogging finds configuration files
Klogging follows these steps for finding configuration files:
- If the environment variable
KLOGGING_CONFIG_PATH
is set, look for a file at that absolute path. Load the contents if found. - If the environment variable is not set or the specified file is not found, search the classpath:
for
klogging.json
and load the contents if found; otherwise forklogging.conf
and load the contents if found.
Once a JSON or HOCON file has been found, it is read.