Smtp

Edward Zborowski edited this page Sep 23, 2015 · 9 revisions

Sends logging events using e-mail (various transports). Uses andris9/Nodemailer module.

Options:

  • recipients - comma separated list of email recipients,
  • sender - sender of all emails (defaults to transport user),
  • subject - subject of all email messages (defaults to first event's message),
  • sendInterval - the time in seconds between sending attempts (defaults to 0); all events are buffered and sent in one email during this time; if 0 then every event sends an email
  • SMTP - default SMTP transport options
  • transport - use custom transport instead of default SMTP transport; object with two keys: plugin, options

Example configuration using default SMTP transport:

{ "appenders": [
    {
        "type": "smtp",
        "recipients": "foo@bar.com",
        "sendInterval": 60,
        "SMTP": {
            "host": "smtp.gmail.com",
            "secure": true,
            "port": 465,
            "auth": {
                "user": "foo@bar.com",
                "pass": "bar_foo"
            }
        }
    }
] }

Example configuration using custom transport:

{ "appenders": [
    {
        "type": "smtp",
        "recipients": "foo@bar.com",
        "sendInterval": 60,
        "transport": {
            "plugin": "sendmail",
            "options": {
                "path": "/usr/sbin/sendmail",
                "args": [ "-t", "-oi", "-oem" ]
            }
        }
    }
] }

Most likely you only want to get mails for the fatal, error and warn logging levels, but not for trace, debug and so on. The way to do this is using a logLevelFilter:

{ "appenders": [
    {
        "type": "logLevelFilter",
        "level": "WARN",
        "maxLevel": "FATAL",
        "appender": {
            "type": "smtp",
            "recipients": "foo@bar.com",
            "sendInterval": 60,
            "SMTP": {
                "host": "smtp.gmail.com",
                "secure": true,
                "port": 465,
                "auth": {
                    "user": "foo@bar.com",
                    "pass": "bar_foo"
                }
            }
        }
    }
] }