Skip to content

Loggers

options.loggers lists where the logs go. There are two types: CONSOLE and FILE. When loggers is not set, the server logs to the console only; "loggers": [] turns logging off.

Console and file logs
{
"$schema": "https://raw.githubusercontent.com/loopingz/smtp-relay/main/config.schema.json",
"flows": {
"local": {
"filters": [{ "type": "whitelist", "ips": ["127.0.0.1"] }],
"outputs": [{ "type": "log" }]
}
},
"options": {
"authOptional": true,
"loggers": [
{ "type": "CONSOLE", "level": "INFO" },
{ "type": "FILE", "level": "DEBUG", "filepath": "./smtp.log", "sizeLimit": 50000000 }
]
}
}

level is one of ERROR, WARN, INFO, DEBUG and TRACE. A logger without level uses the LOG_LEVEL environment variable, and INFO when it is not set.

At INFO, the server logs each accepted email (sender, recipients and flow), each refusal, the recipients no flow delivered, and output errors. The SMTP protocol exchanges of the underlying server are logged at DEBUG: use it to troubleshoot a client.

The log output, and the progress messages of the aws and gcp outputs (“Storing…”, “Publishing cloudevent…”), are printed to the console directly: they do not go through these loggers, so a FILE logger does not get them and "loggers": [] does not silence them.

format sets the layout of a line: %(d)s is the date, %(l)s the level and %(m)s the message. The default is %(d)s [%(l)s] %(m)s.

A FILE logger appends to filepath. When the file reaches sizeLimit bytes, it is renamed with a number appended (smtp.log2, smtp.log3…) and a new file is started; 0 disables the rotation.

OptionTypeDescription
formatstring
default "%(d)s [%(l)s] %(m)s"

Format of a log line, %(d)s is the date, %(l)s the level and %(m)s the message

level"ERROR" | "WARN" | "INFO" | "DEBUG" | "TRACE"

Minimum level of the messages to log

typerequired"CONSOLE"
OptionTypeDescription
filepathrequiredstring

Path of the log file

formatstring
default "%(d)s [%(l)s] %(m)s"

Format of a log line, %(d)s is the date, %(l)s the level and %(m)s the message

level"ERROR" | "WARN" | "INFO" | "DEBUG" | "TRACE"

Minimum level of the messages to log

sizeLimitrequirednumber

Size in bytes from which the file is rotated, 0 disables the rotation

typerequired"FILE"