103 |
- |
1 |
# Monolog - Logging for PHP [](https://travis-ci.org/Seldaek/monolog)
|
|
|
2 |
|
|
|
3 |
[](https://packagist.org/packages/monolog/monolog)
|
|
|
4 |
[](https://packagist.org/packages/monolog/monolog)
|
|
|
5 |
[](https://www.versioneye.com/php/monolog:monolog/references)
|
|
|
6 |
|
|
|
7 |
|
|
|
8 |
Monolog sends your logs to files, sockets, inboxes, databases and various
|
|
|
9 |
web services. See the complete list of handlers below. Special handlers
|
|
|
10 |
allow you to build advanced logging strategies.
|
|
|
11 |
|
|
|
12 |
This library implements the [PSR-3](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md)
|
|
|
13 |
interface that you can type-hint against in your own libraries to keep
|
|
|
14 |
a maximum of interoperability. You can also use it in your applications to
|
|
|
15 |
make sure you can always use another compatible logger at a later time.
|
|
|
16 |
As of 1.11.0 Monolog public APIs will also accept PSR-3 log levels.
|
|
|
17 |
Internally Monolog still uses its own level scheme since it predates PSR-3.
|
|
|
18 |
|
|
|
19 |
## Installation
|
|
|
20 |
|
|
|
21 |
Install the latest version with
|
|
|
22 |
|
|
|
23 |
```bash
|
|
|
24 |
$ composer require monolog/monolog
|
|
|
25 |
```
|
|
|
26 |
|
|
|
27 |
## Basic Usage
|
|
|
28 |
|
|
|
29 |
```php
|
|
|
30 |
<?php
|
|
|
31 |
|
|
|
32 |
use Monolog\Logger;
|
|
|
33 |
use Monolog\Handler\StreamHandler;
|
|
|
34 |
|
|
|
35 |
// create a log channel
|
|
|
36 |
$log = new Logger('name');
|
|
|
37 |
$log->pushHandler(new StreamHandler('path/to/your.log', Logger::WARNING));
|
|
|
38 |
|
|
|
39 |
// add records to the log
|
|
|
40 |
$log->addWarning('Foo');
|
|
|
41 |
$log->addError('Bar');
|
|
|
42 |
```
|
|
|
43 |
|
|
|
44 |
## Documentation
|
|
|
45 |
|
|
|
46 |
- [Usage Instructions](doc/01-usage.md)
|
|
|
47 |
- [Handlers, Formatters and Processors](doc/02-handlers-formatters-processors.md)
|
|
|
48 |
- [Utility classes](doc/03-utilities.md)
|
|
|
49 |
- [Extending Monolog](doc/04-extending.md)
|
|
|
50 |
|
|
|
51 |
## Third Party Packages
|
|
|
52 |
|
|
|
53 |
Third party handlers, formatters and processors are
|
|
|
54 |
[listed in the wiki](https://github.com/Seldaek/monolog/wiki/Third-Party-Packages). You
|
|
|
55 |
can also add your own there if you publish one.
|
|
|
56 |
|
|
|
57 |
## About
|
|
|
58 |
|
|
|
59 |
### Requirements
|
|
|
60 |
|
|
|
61 |
- Monolog works with PHP 5.3 or above, and is also tested to work with HHVM.
|
|
|
62 |
|
|
|
63 |
### Submitting bugs and feature requests
|
|
|
64 |
|
|
|
65 |
Bugs and feature request are tracked on [GitHub](https://github.com/Seldaek/monolog/issues)
|
|
|
66 |
|
|
|
67 |
### Framework Integrations
|
|
|
68 |
|
|
|
69 |
- Frameworks and libraries using [PSR-3](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md)
|
|
|
70 |
can be used very easily with Monolog since it implements the interface.
|
|
|
71 |
- [Symfony2](http://symfony.com) comes out of the box with Monolog.
|
|
|
72 |
- [Silex](http://silex.sensiolabs.org/) comes out of the box with Monolog.
|
|
|
73 |
- [Laravel 4 & 5](http://laravel.com/) come out of the box with Monolog.
|
|
|
74 |
- [Lumen](http://lumen.laravel.com/) comes out of the box with Monolog.
|
|
|
75 |
- [PPI](http://www.ppi.io/) comes out of the box with Monolog.
|
|
|
76 |
- [CakePHP](http://cakephp.org/) is usable with Monolog via the [cakephp-monolog](https://github.com/jadb/cakephp-monolog) plugin.
|
|
|
77 |
- [Slim](http://www.slimframework.com/) is usable with Monolog via the [Slim-Monolog](https://github.com/Flynsarmy/Slim-Monolog) log writer.
|
|
|
78 |
- [XOOPS 2.6](http://xoops.org/) comes out of the box with Monolog.
|
|
|
79 |
- [Aura.Web_Project](https://github.com/auraphp/Aura.Web_Project) comes out of the box with Monolog.
|
|
|
80 |
- [Nette Framework](http://nette.org/en/) can be used with Monolog via [Kdyby/Monolog](https://github.com/Kdyby/Monolog) extension.
|
|
|
81 |
- [Proton Micro Framework](https://github.com/alexbilbie/Proton) comes out of the box with Monolog.
|
|
|
82 |
|
|
|
83 |
### Author
|
|
|
84 |
|
|
|
85 |
Jordi Boggiano - <j.boggiano@seld.be> - <http://twitter.com/seldaek><br />
|
|
|
86 |
See also the list of [contributors](https://github.com/Seldaek/monolog/contributors) which participated in this project.
|
|
|
87 |
|
|
|
88 |
### License
|
|
|
89 |
|
|
|
90 |
Monolog is licensed under the MIT License - see the `LICENSE` file for details
|
|
|
91 |
|
|
|
92 |
### Acknowledgements
|
|
|
93 |
|
|
|
94 |
This library is heavily inspired by Python's [Logbook](http://packages.python.org/Logbook/)
|
|
|
95 |
library, although most concepts have been adjusted to fit to the PHP world.
|