Use YAML to configure a remote syslog service. Due to a limitation in the TOML spec, you cannot configure a remote syslog service using TOML.
If there is no log configuration file provided, the default is to create an
error log and a debug log. Theses files will be stored in the log directory
log_dir) in a location determined by the
variable. For more information, see
Path Configuration File.
The names of the validator log files are:
For Python transaction processors, the author determines the name of the log file. It is highly encouraged that the file names are unique for each running processor to avoid naming conflicts. The example transaction processors provided with the SDK uses the following naming convention:
To change the default logging behavior of a Sawtooth component, such as the validator, put a log configuration file in the config directory (see Path Configuration File).
The validator log config file should be named
Each transaction processor can define its own config file. The name of this file is determined by the author. The transaction processors included in the Python SDK use the following naming convention:
For example, the IntegerKey (
intkey) log configuration file is
Configure a Specific Logger¶
If the default logs give too much information, you can configure a specific logger that will only report on the area of the code you are interested in.
log_config.toml file creates a handler that only writes
interconnect logs to the directory and file specified.
version = 1 disable_existing_loggers = false [formatters.simple] format = "[%(asctime)s.%(msecs)03d [%(threadName)s] %(module)s %(levelname)s] %(message)s" datefmt = "%H:%M:%S" [handlers.interconnect] level = "DEBUG" formatter = "simple" class = "logging.FileHandler" filename = "path/filename.log" [loggers."sawtooth_validator.networking.interconnect"] level = "DEBUG" propagate = true handlers = [ "interconnect"]
The formatter and log level can also be specified to provide the exact information you want in your logs.
Rotating File Handler¶
Below is an example of how to setup rotating logs. This is useful when the logs may grow very large, such as with a long-running network. For example:
[formatters.simple] format = "[%(asctime)s.%(msecs)03d [%(threadName)s] %(module)s %(levelname)s] %(message)s" datefmt = "%H:%M:%S" [handlers.interconnect] level = "DEBUG" formatter = "simple" class = "logging.handlers.RotatingFileHandler" filename = "example-interconnect.log" maxBytes = 50000000 backupCount=20 [loggers."sawtooth_validator.networking.interconnect"] level = "DEBUG" propagate = true handlers = [ "interconnect"]
If one file exceeds the
maxBytes set in the config file, that file will be
filename.log.1 and a new
filename.log will be written to.
This process continues for the number of files plus one set in the
backupCount. After that point, the file that is being written to is rotated.
The current file being written to is always
For more Python configuration options, see the Python documentation at https://docs.python.org/3/library/logging.config.html.