Log Configuration
EMQX Edge allows flexible customization of how the broker generates and manages log files. You configure the log destination, log level, and log rotation strategy to suit your deployment needs.
Example Configuration
hcl
log = {
to = [file, console] # Destination of the logs
level = "warn" # Log level
dir = "/tmp" # Directory for log files
file = "nanomq.log" # Filename for the log file
rotation = {
size = "10MB" # Maximum size of each log file
count = 5 # Maximum rotation count of log files
}
}
To enable automatic directory creation, simply add a trailing /
to the dir
parameter to indicate it is a folder.
For example, to auto-create the "/tmp/nanomq/log/" folder if it does not exist, you can use the following configuration:
log = {
to = [file, console]
level = "warn"
dir = "/tmp/nanomq/log/" # Will be created automatically if it doesn’t exist
}
Configuration Items
to
: Specifies the destination(s) where the logs will be emitted. Optional values:file
: Write logs to a file.console
: Write logs to standard I/Osyslog
: Write logs to syslog
level
: Specifies the log level. Only messages with a severity level equal to or higher than this level will be logged. Optional values:trace
debug
info
warn
error
fatal
dir
: Specifies the directory where log files will be stored.file
: Specifies the filename for the log file.rotation
: Specifies the settings for log file rotation.size
: Specifies the maximum size of each log file. Once a log file reaches this size, it will be rotated. The value can be specified in KB, MB, or GB.count
: Specifies the maximum rotation count of log files. When the count limit is reached, the oldest log file will be deleted upon the next rotation.
Changes to logging configuration can only take effect after restarting the broker.