monolog README

The project's README from github.com/Seldaek/monolog. As one markdown file: README.md.

Monolog

Monolog - Logging for PHP Continuous Integration

Total Downloads Latest Stable Version

Note This is the documentation for Monolog 3.x, if you are using older releases see the documentation for Monolog 2.x or Monolog 1.x

Monolog sends your logs to files, sockets, inboxes, databases and various web services. See the complete list of handlers below. Special handlers allow you to build advanced logging strategies.

This library implements the PSR-3 interface that you can type-hint against in your own libraries to keep a maximum of interoperability. You can also use it in your applications to make sure you can always use another compatible logger at a later time. As of 1.11.0 Monolog public APIs will also accept PSR-3 log levels. Internally Monolog still uses its own level scheme since it predates PSR-3.


Sponsored by:
Better Stack
Better Stack lets you centralize, search, and visualize your logs.


Installation

Install the latest version with

composer require monolog/monolog

Basic Usage

<?php

use Monolog\Level;
use Monolog\Logger;
use Monolog\Handler\StreamHandler;

// create a log channel
$log = new Logger('name');
$log->pushHandler(new StreamHandler('path/to/your.log', Level::Warning));

// add records to the log
$log->warning('Foo');
$log->error('Bar');

Documentation

Support Monolog Financially

Get supported Monolog and help fund the project with the Tidelift Subscription or via GitHub sponsorship.

Tidelift delivers commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use.

Third Party Packages

Third party handlers, formatters and processors are listed in the wiki. You can also add your own there if you publish one.

About

Requirements

Support

Monolog 1.x support is somewhat limited at this point and only important fixes will be done. You should migrate to Monolog 2 or 3 where possible to benefit from all the latest features and fixes.

Submitting bugs and feature requests

Bugs and feature request are tracked on GitHub

Framework Integrations

Author

Jordi Boggiano - [email protected] - http://twitter.com/seldaek
See also the list of contributors who participated in this project.

License

Monolog is licensed under the MIT License - see the LICENSE file for details

Acknowledgements

This library is heavily inspired by Python's Logbook library, although most concepts have been adjusted to fit to the PHP world.

monolog (Seldaek/monolog)

Searching Database…

21.4K ·GitHub
这是什么?Monolog 是一个 PHP 日志库:它会把你的应用产生的日志发送到文件、socket、邮箱、数据库以及各种网络服务。
它是我加到自己代码里的库,还是一个单独的日志服务?它是安装到你的 PHP 代码里的库,不是一个需要运行的服务。它实现了 PSR-3 日志接口,所以你可以对 PSR-3 做类型提示,以后随时换成其他兼容的日志库。
我怎么把它加到我的项目里?用 Composer 安装:composer require monolog/monolog。然后为你需要的目标位置挂上 handler,并通过 logger API 写日志——文档里介绍了用法、handler、formatter 和 processor。
我需要哪个 PHP 版本?当前的 3.x 系列需要 PHP 8.1 或更高版本。旧版本分支用于老的项目:2.5+ 可以在 PHP 7.2+ 上运行,1.25+ 则支持 PHP 5.3 到 8.1。
我还在用 Monolog 1.x,这有问题吗?时间长了会有问题:1.x 只修复重要问题,不再提供 PHP 兼容性方面的修复,所以 README 建议尽量迁移到 2.x 或 3.x。
它能开箱即用地配合 Laravel 和 Symfony 使用吗?可以——Symfony、Laravel、Lumen、Magento 等多个框架本身就自带 Monolog,而 CakePHP、Yii 2、Drupal 和 Nette 则通过专门的桥接插件来接入。
它除了把日志写到文件,还能做别的吗?可以——专门的 handler 让你搭建高级的日志策略,handler、formatter 和 processor 都是可以自由组合的积木,第三方的组件在项目 wiki 里有列出。
它支持哪些日志级别?从 1.11.0 版本开始,它的公开 API 也接受 PSR-3 日志级别;在内部 Monolog 保留着自己的一套级别方案,因为这个库比 PSR-3 出现得更早。
Monolog 有付费的商业支持吗?有——Tidelift Subscription 为这个依赖提供商业支持和维护,你也可以通过 GitHub 赞助直接资助这个项目。
What are similar projects?loguru, pino, log, Slim, whoops, logger, timber, gofr
Creator
Seldaek
Size
5.1 MB
Stars
21.4K
Age
15y
Commits · 90 Days