System Logging
MPC node system logging can be configured in the MPC node's configuration file. You can configure a default logger like this:
[Log]
# Log level. Possible values are INFO, WARN, ERROR and DEBUG. Defaults to INFO if not set.
Level = "INFO"
# Log format. Possible values are TEXT and JSON. If not specified it default to TEXT.
Format = "TEXT"
# If specified, logs will be written to this file. If empty, logs will be written to standard
# out.
FilePath = ""
# Set to true to log the filename and line number where the logging operation occurred.
ReportCaller = true
Advanced Logging
For more advanced logging configuration, you can specify one or more of the [Log.X]
configuration sections. If any of these configurations are specified, they will override the top level configuration.
Logging to stdout
# This logger logs to standard out.
[Log.StdoutLogger]
# Log level. Possible values are INFO, WARN, ERROR and DEBUG. If not specified it default
# to INFO.
Level = "INFO"
# Log format. Possible values are TEXT and JSON. If not specified it default to TEXT.
Format = "TEXT"
# Set to true to log the filename and line number where the logging operation occurred.
ReportCaller = true
Logging to files
It is also possible to log to one or more files, by specifying one or more sections like this:
[[Log.FileLoggers]]
# Log level. Possible values are INFO, WARN, ERROR and DEBUG. If not specified it default
# to INFO.
Level = "INFO"
# Log format. Possible values are TEXT and JSON. If not specified it default to TEXT.
Format = "TEXT"
# Log to this file. If it does not exist, it will be created.
FilePath = "/path/to/a/logfile"
# Set to true to log the filename and line number where the logging operation occurred.
#ReportCaller = true
Logging to syslog
Logging to syslog can be configured like this:
[Log.SyslogLogger]
# Log level. Possible values are INFO, WARN, ERROR and DEBUG. Defaults to INFO if not set.
Level = "INFO"
# Log format. Possible values are TEXT and JSON. If not specified it default to TEXT.
Format = "TEXT"
# Set to true to log the filename and line number where the logging operation occurred.
#ReportCaller = true
Logging to AWS CloudWatch
[Log.CloudWatchLogger]
# Log level. Possible values are INFO, WARN, ERROR and DEBUG. If not specified it default
# to INFO.
Level = "INFO"
# Specify the AWS region here. This field is required.
#Region = ""
# Specify the AWS log group name. This field is required.
#LogGroupName = ""
# Specify the AWS log stream name. This field is required.
#LogStreamName = ""
# Set to true to log the filename and line number where the logging operation occurred.
#ReportCaller = true
Separate Log Configuration
In some cases it may make sense to configure logging in a separate configuration file, instead of the primary MPC node config file. As with the main configuration, it works as follows: When the MPC node starts up, it first attempts to base64 decode the contents of the LOG_CONFIG_BASE64
environment variable. If this is not defined, it attempts to read the log configuration from the file specified in LOG_CONFIG_FILE
.
If no logging is configured, the default configuration will be used, as shown here:
# Log level. If not specified it defaults to "info".
# Possible values are "panic", "fatal", "error", "warn", "warning", "info", "debug", "trace".
Level = "INFO"
# File path. If specified, the node will log to the file at path. Otherwise stdout is used.
FilePath = ""
# Report caller. If true, the log will show where the log call was made. Defaults to true.
ReportCaller = true
Updated 3 months ago