Monolog is a full and easy-to-expand Logging Component in php. Currently, many well-known php frameworks, including Symfony, Laravel, and CakePHP, have built-in Monolog. Monolog can send your logs to files, sockets, inbox, databases, and various web servers. Some special components can bring you special log policies. Enable
Monolog is a full and easy-to-expand Logging Component in php. Currently, many well-known php frameworks, including Symfony, Laravel, and CakePHP, have built-in Monolog. Monolog can send your logs to files, sockets, inbox, databases, and various web servers. Some special components can bring you special log policies. Enable
Monolog is a full and easy-to-expand Logging Component in php. Currently, many well-known php frameworks, including Symfony, Laravel, and CakePHP, have built-in Monolog.
Monolog can send your logs to files, sockets, inbox, databases, and various web servers. Some special components can bring you special log policies.
Example
|
1
2
3
4
5
6
7
8
9
10
11
12 |
use Monolog\Logger;
use Monolog\Handler\StreamHandler;
// create a log channel
$log = new Logger('name');
$log->pushHandler(newStreamHandler('path/to/your.log', Logger::WARNING));
// add records to the log
$log->addWarning('Foo');
$log->addError('Bar');
|
Core concepts
Each Logger instance has a channel and a log processor stack. Every time you add a log record, it will be sent to the log processor stack. You can create manyLogger,Each Logger defines a channel (db, request, route), and each Logger has many log processors. These channels filter logs.
Each log processor has a Formatter (a built-in log display format processor ). You can also set the log level.
Log Level
- DEBUG: Detailed debug information
- INFO: events of interest. Like user logon, SQL logs
- NOTICE: A normal but significant event.
- WARNING:When an exception occurs, an outdated API is used.
- ERROR: an ERROR occurs during running. The ERROR must be recorded and monitored, but the ERROR does not need to be handled immediately.
- CRITICAL: CRITICAL errors, such as application component unavailability.
- ALETR: an error that requires immediate action, such as the failure of the entire website and unavailability of the database. At this time, the trigger will notify you via SMS,
Github Website: https://github.com/seldaek/monolog, 网http://monolog.ow2.org /.