| Class | Logging::Appenders::Email |
| In: |
lib/logging/appenders/email.rb
|
| Parent: | ::Logging::Appender |
Provides an appender that can send log messages via email to a list of recipients.
| address | [RW] | |
| authentication | [R] | |
| domain | [RW] | |
| enable_starttls_auto | [RW] | |
| from | [RW] | |
| password | [RW] | |
| port | [R] | |
| subject | [RW] | |
| to | [R] | |
| user_name | [RW] |
Create a new email appender that will buffer messages and then send them out in batches to the listed recipients. See the options below to configure how emails are sent through you mail server of choice. All the buffering options apply to the email appender.
The following options are required:
:from - The base filename to use when constructing new log
filenames.
:to - The list of email recipients either as an Array or a comma
separated list.
The following options are optional:
:subject - The subject line for the email.
:address - Allows you to use a remote mail server. Just change it
from its default "localhost" setting.
:port - On the off chance that your mail server doesn't run on
port 25, you can change it.
:domain - If you need to specify a HELO domain, you can do it here.
:user_name - If your mail server requires authentication, set the user
name in this setting.
:password - If your mail server requires authentication, set the
password in this setting.
:authentication - If your mail server requires authentication, you need
to specify the authentication type here. This is a
symbol and one of :plain (will send the password in
the clear), :login (will send password Base64
encoded) or :cram_md5 (combines a Challenge/Response
mechanism to exchange information and a cryptographic
Message Digest 5 algorithm to hash important
information)
:enable_starttls_auto - When set to true, detects if STARTTLS is
enabled in your SMTP server and starts to use it.
Example:
Setup an email appender that will buffer messages for up to 1 minute, and only send messages for ERROR and FATAL messages. This example uses Google‘s SMTP server with authentication to send out messages.
Logger.appenders.email( 'email',
:from => "server@example.com",
:to => "developers@example.com",
:subject => "Application Error [#{%x(uname -n).strip}]",
:address => "smtp.google.com",
:port => 443,
:domain => "google.com",
:user_name => "example",
:password => "12345",
:authentication => :plain,
:enable_starttls_auto => true,
:auto_flushing => 200, # send an email after 200 messages have been buffered
:flush_period => 60, # send an email after one minute
:level => :error # only process log events that are "error" or "fatal"
)
If your mail server requires authentication, you need to specify the authentication type here. This is a symbol and one of :plain (will send the password in the clear), :login (will send password Base64 encoded) or :cram_md5 (combines a Challenge/Response mechanism to exchange information and a cryptographic Message Digest 5 algorithm to hash important information)