scratch – Blame information for rev

Subversion Repositories:
Rev:
Rev Author Line No. Line
115 office 1 # Handlers, Formatters and Processors
2  
3 - [Handlers](#handlers)
4 - [Log to files and syslog](#log-to-files-and-syslog)
5 - [Send alerts and emails](#send-alerts-and-emails)
6 - [Log specific servers and networked logging](#log-specific-servers-and-networked-logging)
7 - [Logging in development](#logging-in-development)
8 - [Log to databases](#log-to-databases)
9 - [Wrappers / Special Handlers](#wrappers--special-handlers)
10 - [Formatters](#formatters)
11 - [Processors](#processors)
12 - [Third Party Packages](#third-party-packages)
13  
14 ## Handlers
15  
16 ### Log to files and syslog
17  
18 - _StreamHandler_: Logs records into any PHP stream, use this for log files.
19 - _RotatingFileHandler_: Logs records to a file and creates one logfile per day.
20 It will also delete files older than `$maxFiles`. You should use
21 [logrotate](http://linuxcommand.org/man_pages/logrotate8.html) for high profile
22 setups though, this is just meant as a quick and dirty solution.
23 - _SyslogHandler_: Logs records to the syslog.
24 - _ErrorLogHandler_: Logs records to PHP's
25 [`error_log()`](http://docs.php.net/manual/en/function.error-log.php) function.
26  
27 ### Send alerts and emails
28  
29 - _NativeMailerHandler_: Sends emails using PHP's
30 [`mail()`](http://php.net/manual/en/function.mail.php) function.
31 - _SwiftMailerHandler_: Sends emails using a [`Swift_Mailer`](http://swiftmailer.org/) instance.
32 - _PushoverHandler_: Sends mobile notifications via the [Pushover](https://www.pushover.net/) API.
33 - _HipChatHandler_: Logs records to a [HipChat](http://hipchat.com) chat room using its API.
34 - _FlowdockHandler_: Logs records to a [Flowdock](https://www.flowdock.com/) account.
35 - _SlackHandler_: Logs records to a [Slack](https://www.slack.com/) account using the Slack API.
36 - _SlackbotHandler_: Logs records to a [Slack](https://www.slack.com/) account using the Slackbot incoming hook.
37 - _SlackWebhookHandler_: Logs records to a [Slack](https://www.slack.com/) account using Slack Webhooks.
38 - _MandrillHandler_: Sends emails via the Mandrill API using a [`Swift_Message`](http://swiftmailer.org/) instance.
39 - _FleepHookHandler_: Logs records to a [Fleep](https://fleep.io/) conversation using Webhooks.
40 - _IFTTTHandler_: Notifies an [IFTTT](https://ifttt.com/maker) trigger with the log channel, level name and message.
41  
42 ### Log specific servers and networked logging
43  
44 - _SocketHandler_: Logs records to [sockets](http://php.net/fsockopen), use this
45 for UNIX and TCP sockets. See an [example](sockets.md).
46 - _AmqpHandler_: Logs records to an [amqp](http://www.amqp.org/) compatible
47 server. Requires the [php-amqp](http://pecl.php.net/package/amqp) extension (1.0+).
48 - _GelfHandler_: Logs records to a [Graylog2](http://www.graylog2.org) server.
49 - _CubeHandler_: Logs records to a [Cube](http://square.github.com/cube/) server.
50 - _RavenHandler_: Logs records to a [Sentry](http://getsentry.com/) server using
51 [raven](https://packagist.org/packages/raven/raven).
52 - _ZendMonitorHandler_: Logs records to the Zend Monitor present in Zend Server.
53 - _NewRelicHandler_: Logs records to a [NewRelic](http://newrelic.com/) application.
54 - _LogglyHandler_: Logs records to a [Loggly](http://www.loggly.com/) account.
55 - _RollbarHandler_: Logs records to a [Rollbar](https://rollbar.com/) account.
56 - _SyslogUdpHandler_: Logs records to a remote [Syslogd](http://www.rsyslog.com/) server.
57 - _LogEntriesHandler_: Logs records to a [LogEntries](http://logentries.com/) account.
58  
59 ### Logging in development
60  
61 - _FirePHPHandler_: Handler for [FirePHP](http://www.firephp.org/), providing
62 inline `console` messages within [FireBug](http://getfirebug.com/).
63 - _ChromePHPHandler_: Handler for [ChromePHP](http://www.chromephp.com/), providing
64 inline `console` messages within Chrome.
65 - _BrowserConsoleHandler_: Handler to send logs to browser's Javascript `console` with
66 no browser extension required. Most browsers supporting `console` API are supported.
67 - _PHPConsoleHandler_: Handler for [PHP Console](https://chrome.google.com/webstore/detail/php-console/nfhmhhlpfleoednkpnnnkolmclajemef), providing
68 inline `console` and notification popup messages within Chrome.
69  
70 ### Log to databases
71  
72 - _RedisHandler_: Logs records to a [redis](http://redis.io) server.
73 - _MongoDBHandler_: Handler to write records in MongoDB via a
74 [Mongo](http://pecl.php.net/package/mongo) extension connection.
75 - _CouchDBHandler_: Logs records to a CouchDB server.
76 - _DoctrineCouchDBHandler_: Logs records to a CouchDB server via the Doctrine CouchDB ODM.
77 - _ElasticSearchHandler_: Logs records to an Elastic Search server.
78 - _DynamoDbHandler_: Logs records to a DynamoDB table with the [AWS SDK](https://github.com/aws/aws-sdk-php).
79  
80 ### Wrappers / Special Handlers
81  
82 - _FingersCrossedHandler_: A very interesting wrapper. It takes a logger as
83 parameter and will accumulate log records of all levels until a record
84 exceeds the defined severity level. At which point it delivers all records,
85 including those of lower severity, to the handler it wraps. This means that
86 until an error actually happens you will not see anything in your logs, but
87 when it happens you will have the full information, including debug and info
88 records. This provides you with all the information you need, but only when
89 you need it.
90 - _DeduplicationHandler_: Useful if you are sending notifications or emails
91 when critical errors occur. It takes a logger as parameter and will
92 accumulate log records of all levels until the end of the request (or
93 `flush()` is called). At that point it delivers all records to the handler
94 it wraps, but only if the records are unique over a given time period
95 (60seconds by default). If the records are duplicates they are simply
96 discarded. The main use of this is in case of critical failure like if your
97 database is unreachable for example all your requests will fail and that
98 can result in a lot of notifications being sent. Adding this handler reduces
99 the amount of notifications to a manageable level.
100 - _WhatFailureGroupHandler_: This handler extends the _GroupHandler_ ignoring
101 exceptions raised by each child handler. This allows you to ignore issues
102 where a remote tcp connection may have died but you do not want your entire
103 application to crash and may wish to continue to log to other handlers.
104 - _BufferHandler_: This handler will buffer all the log records it receives
105 until `close()` is called at which point it will call `handleBatch()` on the
106 handler it wraps with all the log messages at once. This is very useful to
107 send an email with all records at once for example instead of having one mail
108 for every log record.
109 - _GroupHandler_: This handler groups other handlers. Every record received is
110 sent to all the handlers it is configured with.
111 - _FilterHandler_: This handler only lets records of the given levels through
112 to the wrapped handler.
113 - _SamplingHandler_: Wraps around another handler and lets you sample records
114 if you only want to store some of them.
115 - _NullHandler_: Any record it can handle will be thrown away. This can be used
116 to put on top of an existing handler stack to disable it temporarily.
117 - _PsrHandler_: Can be used to forward log records to an existing PSR-3 logger
118 - _TestHandler_: Used for testing, it records everything that is sent to it and
119 has accessors to read out the information.
120 - _HandlerWrapper_: A simple handler wrapper you can inherit from to create
121 your own wrappers easily.
122  
123 ## Formatters
124  
125 - _LineFormatter_: Formats a log record into a one-line string.
126 - _HtmlFormatter_: Used to format log records into a human readable html table, mainly suitable for emails.
127 - _NormalizerFormatter_: Normalizes objects/resources down to strings so a record can easily be serialized/encoded.
128 - _ScalarFormatter_: Used to format log records into an associative array of scalar values.
129 - _JsonFormatter_: Encodes a log record into json.
130 - _WildfireFormatter_: Used to format log records into the Wildfire/FirePHP protocol, only useful for the FirePHPHandler.
131 - _ChromePHPFormatter_: Used to format log records into the ChromePHP format, only useful for the ChromePHPHandler.
132 - _GelfMessageFormatter_: Used to format log records into Gelf message instances, only useful for the GelfHandler.
133 - _LogstashFormatter_: Used to format log records into [logstash](http://logstash.net/) event json, useful for any handler listed under inputs [here](http://logstash.net/docs/latest).
134 - _ElasticaFormatter_: Used to format log records into an Elastica\Document object, only useful for the ElasticSearchHandler.
135 - _LogglyFormatter_: Used to format log records into Loggly messages, only useful for the LogglyHandler.
136 - _FlowdockFormatter_: Used to format log records into Flowdock messages, only useful for the FlowdockHandler.
137 - _MongoDBFormatter_: Converts \DateTime instances to \MongoDate and objects recursively to arrays, only useful with the MongoDBHandler.
138  
139 ## Processors
140  
141 - _PsrLogMessageProcessor_: Processes a log record's message according to PSR-3 rules, replacing `{foo}` with the value from `$context['foo']`.
142 - _IntrospectionProcessor_: Adds the line/file/class/method from which the log call originated.
143 - _WebProcessor_: Adds the current request URI, request method and client IP to a log record.
144 - _MemoryUsageProcessor_: Adds the current memory usage to a log record.
145 - _MemoryPeakUsageProcessor_: Adds the peak memory usage to a log record.
146 - _ProcessIdProcessor_: Adds the process id to a log record.
147 - _UidProcessor_: Adds a unique identifier to a log record.
148 - _GitProcessor_: Adds the current git branch and commit to a log record.
149 - _TagProcessor_: Adds an array of predefined tags to a log record.
150  
151 ## Third Party Packages
152  
153 Third party handlers, formatters and processors are
154 [listed in the wiki](https://github.com/Seldaek/monolog/wiki/Third-Party-Packages). You
155 can also add your own there if you publish one.
156  
157 ← [Usage](01-usage.md) | [Utility classes](03-utilities.md) →