The `Logger` class provides a consistent, application-wide interface for configuring and writing
log messages. As with other subclasses of `Adaptable`, `Logger` can be configured with a series
of named configurations, each containing a log adapter to write to. `Logger` exposes a single
method, `write()`, which can write to one or more log adapters.
When configuring adapters, you may specify one or more priorities for each, using the
`'priority'` key. This key can be a single priority level (string), or an array of multiple
levels. When a log message is written, all adapters that are configured to accept the priority
level with which the message was written will receive the message.
{{{
Logger::config(array(
'default' => array('adapter' => 'Syslog'),
'badnews' => array(
'adapter' => 'File',
'priority' => array('emergency', 'alert', 'critical', 'error')
)
));
}}}
In the above configuration, all messages will be written to the system log (`syslogd`), but only
messages with the priority `error` or higher will be logged to a file. Messages can then be
written to the log(s) using the `write()` method:
{{{ Logger::write('alert', 'This is an alert-level message that will be logged in 2 places'); }}}
Messages can also be written using the log priority as a method name:
{{{ Logger::alert('This is an alert-level message that will be logged in 2 places'); }}}
This works identically to the above. The message priority levels which `Logger` supports are as
follows: `emergency`, `alert`, `critical`, `error`, `warning`, `notice`, `info` and `debug`.
Attempting to use any other priority level will raise an exception. See the list of available
adapters for more information on what adapters are available, and how to configure them.