Monolog based, PSR-3 compliant logger, with pluggable architecture and simple configuration.
- Pluggable architecture, semantically versioned
- Simple setup, with autocompletion
- One unified configuration schema
- Plugins can be grouped into sets to easily create customized and very specific loggers instances
- Monolog's handlers and processors constructors details and dependencies are never exposed
- Based on Monolog v3.x
Log everything at level info and above to /tmp/example.log.
$streamPluginConfigurator = (new StreamLoggerPluginConfigurator)
->setLogLevel('info')
->setStreamLocation('/tmp/example.log');
$configurator = (new LoggerConfigurator)
->add($streamPluginConfigurator);
$logger = (new EveronLoggerFacade)->buildLogger($configurator);
$logger->info('lorem ipsum');Content of /tmp/example.log.
[2020-11-15T16:29:16.400318+00:00] everon-logger.INFO: lorem ipsum [] []
The configuration is done by simple data structures called configurators.
Each plugin configurator has its plugin specific settings.
For example, to use syslog and file logging, setup the StreamLoggerPluginConfigurator
and SyslogLoggerPluginConfigurator.
$configurator = (new LoggerConfigurator)
->add(
(new StreamLoggerPluginConfigurator)
->setLogLevel('debug')
->setStreamLocation('/tmp/example.log')
)->add(
(new SyslogLoggerPluginConfigurator)
->setLogLevel('info')
->setIdent('everon-logger-ident'));A logger plugin is used to create and configure corresponding Monolog's handler.
Besides LoggerPluginInterface a plugin can also implement PluginFormatterInterface,
in which case the custom formatter provided by the plugin will be used.
To set up a plugin with given handler, add it to the collection in LoggerConfigurator with add().
For example, setup logging to a redis server and enable memory usage processor.
$redisPluginConfigurator = new RedisLoggerPluginConfigurator;
$redisPluginConfigurator
->setLogLevel('info')
->setKey('redis-queue-test')
->requireRedisConnection()
->setHost('redis.host')
->setTimeout(10);
$configurator = (new LoggerConfigurator)
->setName('everon-logger-example')
->add($redisPluginConfigurator)
->addProcessor(MemoryUsageProcessor::class);
$logger = (new EveronLoggerFacade)->buildLogger($configurator);
$logger->info('lorem ipsum');Content of redis-queue-test in redis.
[2020-11-15T16:39:12.495319+00:00] everon-logger.INFO: lorem ipsum [] {"memory_usage":"6 MB"}
Add required processor classes to logger configurator with addProcessor().
$configurator = (new LoggerConfigurator)
->addProcessor(MemoryUsageProcessor::class)
->addProcessor(HostnameProcessor::class)
->addProcessor(...)
...Set of plugins that require no extra vendor dependencies.
composer require everon/logger-basic
Set of plugins for Graylog2 handlers.
composer require everon/logger-gelf
Set of plugins for Redis handler.
composer require everon/logger-redis
- PHP v8.1.x
- Monolog v3.x
composer require everon/logger
Note: You only need to install this package if you want to develop a plugin for EveronLogger.
Otherwise, install specific plugins. See above.