Handlers

记录日志到文件与系统日志(syslog)

  • StreamHandler:记录日志到任何 PHP stream,用它来记录到文件。
  • RotatingFileHandler: 每天一个文件,会自动删除比$maxFiles老的文件,这只是一个很随意的方案, You should use logrotate for high profile setups though。
  • SyslogHandler: 记录到系统日志
  • ErrorLogHandler: Logs records to PHP's error_log()function.

作者:Kaiyulee
链接:https://www.jianshu.com/p/e6b26eb44e70
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

 

记录到指定server与网络日志

接着看看

SocketHandler: Logs records to sockets, use this for UNIX and TCP sockets. See an example.
AmqpHandler: Logs records to an amqp compatible server. Requires the php-amqp extension (1.0+).
GelfHandler: Logs records to a Graylog2 server.
CubeHandler: Logs records to a Cube server.
RavenHandler: Logs records to a Sentry server using raven.
ZendMonitorHandler: Logs records to the Zend Monitor present in Zend Server.
NewRelicHandler: Logs records to a NewRelic application.
LogglyHandler: Logs records to a Loggly account.
RollbarHandler: Logs records to a Rollbar account.
SyslogUdpHandler: Logs records to a remote Syslogd server.
LogEntriesHandler: Logs records to a LogEntries account.

开发环境中,利用浏览器扩展

装扩展

FirePHPHandler: Handler for FirePHP, providing inline console
messages within FireBug.
ChromePHPHandler: Handler for ChromePHP, providing inline console
messages within Chrome.
BrowserConsoleHandler: Handler to send logs to browser's Javascript console
with no browser extension required. Most browsers supporting console
API are supported.
PHPConsoleHandler: Handler for PHP Console, providing inline console
and notification popup messages within Chrome.

记录到数据库

顾名思义

RedisHandler: Logs records to a redis server.
MongoDBHandler: Handler to write records in MongoDB via a Mongo extension connection.
CouchDBHandler: Logs records to a CouchDB server.
DoctrineCouchDBHandler: Logs records to a CouchDB server via the Doctrine CouchDB ODM.
ElasticSearchHandler: Logs records to an Elastic Search server.
DynamoDbHandler: Logs records to a DynamoDB table with the AWS SDK.

特殊的Handler

慢慢看

FingersCrossedHandler: A very interesting wrapper. It takes a logger as parameter and will accumulate log records of all levels until a record exceeds the defined severity level. At which point it delivers all records, including those of lower severity, to the handler it wraps. This means that until an error actually happens you will not see anything in your logs, but when it happens you will have the full information, including debug and info records. This provides you with all the information you need, but only when you need it.

DeduplicationHandler: Useful if you are sending notifications or emails when critical errors occur. It takes a logger as parameter and will accumulate log records of all levels until the end of the request (or flush()
is called). At that point it delivers all records to the handler it wraps, but only if the records are unique over a given time period (60seconds by default). If the records are duplicates they are simply discarded. The main use of this is in case of critical failure like if your database is unreachable for example all your requests will fail and that can result in a lot of notifications being sent. Adding this handler reduces the amount of notifications to a manageable level.

WhatFailureGroupHandler: This handler extends the GroupHandler ignoring exceptions raised by each child handler. This allows you to ignore issues where a remote tcp connection may have died but you do not want your entire application to crash and may wish to continue to log to other handlers.

BufferHandler: This handler will buffer all the log records it receives until close()
is called at which point it will callhandleBatch()
on the handler it wraps with all the log messages at once. This is very useful to send an email with all records at once for example instead of having one mail for every log record.

GroupHandler: This handler groups other handlers. Every record received is sent to all the handlers it is configured with.

FilterHandler: This handler only lets records of the given levels through to the wrapped handler.

SamplingHandler: Wraps around another handler and lets you sample records if you only want to store some of them.

NullHandler: Any record it can handle will be thrown away. This can be used to put on top of an existing handler stack to disable it temporarily.

PsrHandler: Can be used to forward log records to an existing PSR-3 logger

TestHandler: Used for testing, it records everything that is sent to it and has accessors to read out the information.

HandlerWrapper: A simple handler wrapper you can inherit from to create your own wrappers easily.

Formatters

✪ 为常用

LineFormatter: Formats a log record into a one-line string. ✪
HtmlFormatter: Used to format log records into a human readable html table, mainly suitable for emails.✪
NormalizerFormatter: Normalizes objects/resources down to strings so a record can easily be serialized/encoded.
ScalarFormatter: Used to format log records into an associative array of scalar values.
JsonFormatter: Encodes a log record into json.✪
WildfireFormatter: Used to format log records into the Wildfire/FirePHP protocol, only useful for the FirePHPHandler.
ChromePHPFormatter: Used to format log records into the ChromePHP format, only useful for the ChromePHPHandler.
GelfMessageFormatter: Used to format log records into Gelf message instances, only useful for the GelfHandler.
LogstashFormatter: Used to format log records into logstash event json, useful for any handler listed under inputs here.
ElasticaFormatter: Used to format log records into an Elastica\Document object, only useful for the ElasticSearchHandler.
LogglyFormatter: Used to format log records into Loggly messages, only useful for the LogglyHandler.
FlowdockFormatter: Used to format log records into Flowdock messages, only useful for the FlowdockHandler.
MongoDBFormatter: Converts \DateTime instances to \MongoDate and objects recursively to arrays, only useful with the MongoDBHandler.

Processors

PsrLogMessageProcessor: Processes a log record's message according to PSR-3 rules, replacing {foo}
with the value from $context['foo'].

IntrospectionProcessor: Adds the line/file/class/method from which the log call originated.

WebProcessor: Adds the current request URI, request method and client IP to a log record.

MemoryUsageProcessor: Adds the current memory usage to a log record.

MemoryPeakUsageProcessor: Adds the peak memory usage to a log record.

ProcessIdProcessor: Adds the process id to a log record.

UidProcessor: Adds a unique identifier to a log record.

GitProcessor: Adds the current git branch and commit to a log record.

TagProcessor: Adds an array of predefined tags to a log record.

作者:Kaiyulee
链接:https://www.jianshu.com/p/e6b26eb44e70
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

monolog handler用哪个的更多相关文章

  1. The PHP Package 之 monolog[转]

    Monolog 发送你的日志到文件.到sockets.到邮箱.到数据库或(和)者其他网路存储服务(云).Monolog可以做到同时保存到一个或多个存储介质(后面的栈冒泡处理). 安装   $ comp ...

  2. Monolog - Logging for PHP 5.3+

    Monolog 是PHP的一个日志类库.相比于其他的日志类库,它有以下的特点: 功能强大.可以把日志发送到文件.socket.邮箱.数据库和各种web services. 遵循 PSR3 的接口规范. ...

  3. centos 环境下monolog+php 方案

    1.在项目中,日志系统有多重要详细所有程序员都知道,monolog就是一个最好的解决方案,有各种级别,各种日志存储方式,具体可以上monolog官方了解http://monolog.ow2.org/ ...

  4. 这可能是php世界中最好的日志库——monolog

    由于一些历史原因,php中并没有内建的日志接口,故长期以来也没一个功能完备并且应用广泛的日志库.在我的工作生涯中,如果系统需要记录一些应用日志的话,基本上就是封装一个日志类,然后把一些要记录的字段写入 ...

  5. 记一次Monolog的BufferHandler使用

    laravel中可以设置自定义的日记channel(config/logging中设置),按照laravel-china的一篇文章,把log按一定格式并且以批量的方式写入日志文件: https://l ...

  6. PHP 依赖工具 monolog的使用

    <?phprequire 'vendor/autoload.php'; //自动加载类库 use Monolog\Logger;use Monolog\Handler\StreamHandler ...

  7. monolog 应该是世界上最好的日志插件了

    引入 composer require monolog/monolog 官网 https://github.com/Seldaek/monolog 创建工具类 <?php /** * Creat ...

  8. monolog使用

    安装composer curl -sS https://getcomposer.org/installer | phpmv composer.phar /usr/local/bin/composer ...

  9. php monolog 的写日志到unix domain socket 测试终于成功

    在另外一个客户端执行 php s.php后, 通过nc -lU /tmp/tg.sck 建立的unix domain socket 有接收到消息. <?php require 'vendor/a ...

随机推荐

  1. SpringAOP+源码解析,切就完事了

    本文是对近期学习知识的一个总结,附带源码注释及流程图,如有不足之处,还望评论区批评指正. 目录 一.AOP.SpringAOP.AspectJ的区别 二.AOP关键术语 三.通知的五种类型 四.切入点 ...

  2. oracle之三rman 完全恢复

    rman 完全恢复 8.1 recover 恢复: 1)归档 : 完全恢复和不完全恢复 2)非归档:只能恢复到最后一次备份状态(还原) 8.2 完全恢复: ----先对数据库做一个备份(如果是arch ...

  3. 如何使用dockerfile将jar包生成镜像

    1.编写dockersfile FROM java:8 ADD SPRINGCLOUD.jar app.jar RUN bash -c ‘touch /app.jar’ ENTRYPOINT [&qu ...

  4. 第3课 - makefile伪目标的引入

    第3课 - makefile伪目标的引入 1. makefile 中的目标究竟是什么? (1)默认情况下,make 认为目标对应着一个文件  ==>  目标即文件名 (2)make 首先会检测目 ...

  5. [Java并发编程之美]第2章 synchroized关键字

    ###synchronized关键字 synchronized块是Java提供的一种原子性内置锁,每个对象都可以把它当同步锁来用.线程在进入synchronized块钱会自动获取内部锁,这时候其他线程 ...

  6. Linux下用户的创建与删除

    我们在Linux下创建用户主要有两种方式:adduser和useradd,它们的区别以及主要用法如下: adduser adduser的用法很简单,只需adduser+username即可,如下: s ...

  7. 分布式文件系统之MogileFS的安装使用

    一.简介 MogileFS是一个开源的分布式文件存储系统,由LiveJournal旗下的Danga Interactive公司开发:它主要由三部分组成,第一部分是server端,server端主要包括 ...

  8. vue | vue实现列表同时展开与单独展开

    需求:每个li标签在点击的时候,都同时展开. 但是碰见几个问题: 1.如果点第一个li 所有li都会展开: 2.点击第一个li,第一个li展开,点击第二个li,第一个li闭合,第二个li展开 这两种情 ...

  9. domReady的理解

    domReady的理解 domReady是名为DOMContentLoaded事件的别称,当初始的HTML文档被完全加载和解析完成之后,DOMContentLoaded事件被触发,而无需等待样式表.图 ...

  10. UCanCode发布升级E-Form++可视化源码组件库2020全新版 !

    2020年. 中国.成都 UCanCode发布升级E-Form++可视化源码组件库2020全新版 ! --- 全面性能提升,UCanCode有史以来最强大的版本发布! E-Form++可视化源码组件库 ...