Logging configuration
The Walt.id Enterprise Service uses Klogging as logging provider. The logging can be configured by the use of predefined logging configurations or by specifying a klogging configuration file.
Use predefined logging configuration
Configure log-level
Following predefined loglevel profiles exists:
default, error, debug, trace
The log-level profile can be set with commandline argument --log-level, --logLevel, or -l
Docker Compose example (long commandline argument):
# other services omitted
waltid-enterprise:
image: waltid/waltid-enterprise-api
extra_hosts:
- "localhost:host-gateway"
ports:
- "3000:3000"
command: "--log-level=trace"
# skipped additional required options
Docker Compose example (short commandline argument):
# other services omitted
waltid-enterprise:
image: waltid/waltid-enterprise-api
extra_hosts:
- "localhost:host-gateway"
ports:
- "3000:3000"
command: "-l trace"
# skipped additional required options
The logging profile can also be set with environment variable LOG_LEVEL
Docker Compose example (environment variable):
# other services omitted
waltid-enterprise:
image: waltid/waltid-enterprise-api
extra_hosts:
- "localhost:host-gateway"
ports:
- "3000:3000"
environment:
LOG_LEVEL: "debug"
# skipped additional required options
Configure log-message rendering
Klogging offers a variety of pre-defined log-message formats
The message format can be configured with command line argument (--log-type, --logType) or
environment variable LOG_TYPE
Options:
| LOG_TYPE option | Klogging build in renderers (renderWith option in klogging.json) |
|---|---|
| SIMPLE | RENDER_SIMPLE |
| ISO8601 | RENDER_ISO8601 |
| ANSI | RENDER_ANSI |
| ANSI_LONG | RENDER_ANSI { contextWidth=15, loggerWidth=35 } |
| CLEF | RENDER_CLEF |
| GELF | RENDER_GELF |
| ECS | RENDER_ECS |
| ECS_DOTNET | RENDER_ECS_DOTNET |
| STANDARD | RENDER_STANDARD |
Docker Compose example (environment variable):
# other services omitted
waltid-enterprise:
image: waltid/waltid-enterprise-api
extra_hosts:
- "localhost:host-gateway"
ports:
- "3000:3000"
environment:
LOG_LEVEL: "default"
# the option is only taken into account when LOG_LEVEL is set
LOG_TYPE: "ISO8601"
# skipped additional required options
Use custom logging configuration
Customized logging configuration can be done by configuration file. Information about configuration file can be found here: https://klogging.io/docs/configuration/
The configuration file can be configured by setting environment variable KLOGGING_CONFIG_PATH
If the environment variable is set, it overrides log-level profile configuration
If the environment variable
KLOGGING_CONFIG_PATHis set, look for a file at that absolute path. Load the contents if found.
Example log configuration klogging.json:
{
"kloggingMinLogLevel": "INFO",
"minDirectLogLevel": "INFO",
"sinks": {
"stdout": {
"renderWith": "RENDER_SIMPLE",
"sendTo": "STDOUT"
},
"stderr": {
"renderWith": "RENDER_SIMPLE",
"sendTo": "STDERR"
}
},
"logging": [
{
"comment": "Root logger",
"levelRanges": [
{
"fromMinLevel": "WARN",
"toSinks": [
"stderr"
]
}
]
},
{
"comment": "Default loglevel for all id.walt loggers",
"fromLoggerBase": "id.walt",
"levelRanges": [
{
"fromMinLevel": "INFO",
"toMaxLevel": "INFO",
"toSinks": [
"stdout"
]
}
]
}
]
}
Example Docker configuration to use log-file:
# other services omitted
waltid-enterprise:
image: waltid/waltid-enterprise-api
extra_hosts:
- "localhost:host-gateway"
ports:
- "3000:3000"
environment:
LOG_LEVEL: "default"
LOG_TYPE: "ISO8601"
KLOGGING_CONFIG_PATH: /klogging.json
volumes:
- ./klogging.json:/klogging.json
- ./config:/config
# skipped additional required options
Example Kubernetes configuration:
Log configuration configMap:
apiVersion: v1
kind: ConfigMap
metadata:
name: waltid-enterprise-api-config
namespace: enterprise-main
data:
_features.conf: |
...
auth.conf: |
...
database.conf: |
...
enterprise.conf: |
...
# log only to STDOUT
# log format: "RENDER_STANDARD" (JSON) so it can be picked up and parsed by log aggregator
klogging.json: |
{
"kloggingMinLogLevel": "INFO",
"minDirectLogLevel": "INFO",
"sinks": {
"stdout": {
"renderWith": "RENDER_STANDARD",
"sendTo": "STDOUT"
}
},
"logging": [
{
"comment": "Root logger",
"levelRanges": [
{
"fromMinLevel": "WARN",
"toSinks": [
"stdout"
]
}
]
},
{
"comment": "Walt.id service info",
"matchLogger": "FeatureManager|ConfigManager|Web\s*exception",
"levelRanges": [
{
"fromMinLevel": "INFO",
"toSinks": [
"stdout"
]
}
]
},
{
"comment": "Default loglevel for all id.walt loggers",
"fromLoggerBase": "id.walt",
"levelRanges": [
{
"fromMinLevel": "INFO",
"toMaxLevel": "INFO",
"toSinks": [
"stdout"
]
}
]
},
{
"comment": "Default loglevel for all loggers except Request/Response logger: INFO",
"matchLogger": "^(?!(io\.ktor\.client|WebLog|io\.ktor\.server\.plugins\.cors)).*$",
"levelRanges": [
{
"fromMinLevel": "INFO",
"toMaxLevel": "WARN",
"toSinks": [
"stdout"
]
}
]
},
{
"comment": "Loglevel for http client requests - set it to INFO if you want enable it",
"fromLoggerBase": "io.ktor.client",
"levelRanges": [
{
"fromMinLevel": "WARN",
"toSinks": [
"stout"
]
}
]
}
]
}
resource-access.conf: |
...
superadmin-registration.conf: |
...
web.conf: |
...
