Download the PHP package yapro/monolog-ext without Composer
On this page you can find all versions of the php package yapro/monolog-ext. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download yapro/monolog-ext
More information about yapro/monolog-ext
Files in yapro/monolog-ext
Package monolog-ext
Short Description Very useful extensions for Monolog
License proprietary
Informations about the package monolog-ext
MonologExt
The really useful Monolog`s extensions.
Installation
Add as a requirement in your composer.json
file or run
Configuration of Symfony >= 2.x
You can use the best way to handle your logs because it's the easiest way:
and don't forget to register the handler as a service:
You will get the features:
- writing logs to stderr ( https://12factor.net/logs )
- json representation
- ignoring logs when the client sends an invalid http request (4xx)
- log records of all levels in the application code (src dir, not in vendor dir)
- log records of the NOTICE level and higher in libraries (vendor dir)
- smart a record reducing (removing keys from the record context when the record size exceeds 8192 bytes)
and other features such as development mode.
You can also configure JsonToStdErrHandler:
env var name | default value | example | description |
---|---|---|---|
ERROR_HANDLER_DEV_MODE_PHP_FPM | 0 | 1 | print out important debugging information and stop the execution (comfortable development in php-fpm) |
ERROR_HANDLER_DEV_MODE_PHP_CLI | 0 | 1 | print out important debugging information and stop the execution (comfortable development in php-cli) |
ERROR_HANDLER_MAX_DUMP_LEVEL | 5 | 3 | the nesting level of the objects to be serialized (3 is less detailed level than 5) |
ERROR_HANDLER_IGNORE_RECORD_LEVEL_BELOW | 0 | 250 | errors with a level below the specified one will be ignored (250 is less then NOTICE, 0 == all records) |
ERROR_HANDLER_STOP_REQUEST_WHEN_RECORD_LEVEL_ABOVE | 0 | 200 | an error with a level higher than the specified one will stop the http request with the 500 status |
You can also use the collection of monolog processors, that gives you the opportunity to handle and log different errors.
Add needed for you app to your config.yml
then use logger, examples:
Look up, variable $e will be transformed to string (Monolog`s functionality), and you will get: Message of Exception + Stack trace
By default, \YaPro\MonologExt\VarHelper extract an extra data into string by standard depth's level which is equal to two. But, you can use any depth's level, example is equal a five:
What is ExtraException
ExtraException is exception which you can to create as object, to add the extra data and throw away. After throwing the Monolog ExceptionProcessor will catches this exception and saves extra data to logs. Examples:
Recommendation
Add service json_formatter to file app/config/config.yml It will help you to format error in the json, and then you can use https://www.elastic.co/products/kibana for aggregate all errors.
And don`t forget to add a monolog formatter:
If you wish to collect some data of http request, you can add WebProcessor:
Configuration for projects without Symfony framework.
Monolog Cascade extension gives you the opportunity to handle and log errors of different levels.
Usage
Just use your logger as shown below
Configuring your loggers
Monolog Cascade supports the following config formats:
- Yaml
- JSON
- Php array
Configuration structure
Here is a sample Php array config file:
More detailed information about the configurations - https://github.com/theorchard/monolog-cascade
Tests
Dev
Run tests with xdebug:
All versions of monolog-ext with dependencies
symfony/var-dumper Version ^3.4|^4.4|^5.0|^6.0
monolog/monolog Version ^1.25.1|^2