Logging
Overview
zeknd has built-in configurable logging. The user can configure the log level and the log destination.
#zeknd SDK Logging
#Configuring the log level
The zeknd SDK provides two types of logs:
blockchain logs (blockchain transactions and consensus events).
zeknd SDK logs (generated by the SDK itself, i.e emitted events).
As an example, add the following to your zeknd.yaml
to set logging levels:
Defaults for the zeknd
LogLevel
andBlockchainLogLevel
areinfo
anderror
respectively.
#Configuring the log destination
Currently, a file target is supported for the zeknd logs:
To log to stderr, specify the destination as file://-
#Contract logging
Configurations like log level and destination are separate for contracts. These are set using environment variables.
Example: CONTRACT_LOG_LEVEL=debug CONTRACT_LOG_DESTINATION="file://-" $
zeknd_EXE run
This will set the contract log level to debug
and the destination to stderr.
The default for log level and destination are info
and file://contract.log
respectively.
#Logging from the contract
The contract context has a pre-configured logger that can be used for structured logging. Let's look at an example:
will generate a log line like:
Available methods on the context logger are Error
, Warn
, Info
, and Debug
.
Last updated