Simple wrapper around monolog-cascade adding practical utilities

v1.0.0 2019-04-26 08:22 UTC

This package is auto-updated.

Last update: 2022-11-26 16:47:13 UTC


FlexLog: flexible configurable logging for your applications

Allows reconfiguring the handlers, processor and formatters of your application's loggers through environment variables and config files.

FlexLog is a very thin wrapper around the awesome monolog-cascade library.

It adds:

  • simple initialization based on the config file specified by the FLEX_LOG environment variable
  • ensures that all loggers your application expects are always added to Monolog's Registry, even if no cascade config file is used, or it misses a definition for that logger name.


## Specify a cascade config file (yaml):


At the earliest entry point in your application (index.php, bootstap.php, etc), add the following line to initialize FlexLog:

use FlexLog\FlexLog;

FlexLog::ensureLoggers(['app', 'db', 'caching']); // ensures that loggers with these names exist and are registered

Then, from anywhere in your app, log to monolog as usual. For example by using Monolog's registry:

$username = 'joe';
\Monolog\Registry::app()->info("User {username} logged in", ['username' => $username]);

A fully working example can be found in the test cases in tests/


./vendor/bin/phpunit --bootstrap vendor/autoload.php tests/