PageRenderTime 47ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/vendor/monolog/monolog/doc/02-handlers-formatters-processors.md

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