Monolog: PHP Logging Tool

Source: Internet
Author: User
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

  1. DEBUG: Detailed debug information
  2. INFO: events of interest. Like user logon, SQL logs
  3. NOTICE: A normal but significant event.
  4. WARNING:When an exception occurs, an outdated API is used.
  5. ERROR: an ERROR occurs during running. The ERROR must be recorded and monitored, but the ERROR does not need to be handled immediately.
  6. CRITICAL: CRITICAL errors, such as application component unavailability.
  7. 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 /.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.