Resource icon

xF 2.x Addon Monolog for XenForo 2 2.1.0

Không có quyền tải xuống
This XenForo 2.0 addon adds logging functionality using the Monolog library from

Usage Instructions

By default, this addon will log events to a file called internal_data/monolog.log - in later versions this will be configurable.

To use the default logging facility, do the following in your addon code:

/** @var Monolog\Logger $logger */
$logger = \XF::app()['monolog']->default();

$logger->info('an info message', ['context' => 'foo']);

$logger->error('an error message', ['context' => 'bar']);
However, it is recommended that you create your own channel for your addon to make it easier to filter log entries:

/** @var Monolog\Logger $logger */
$logger = \XF::app()['monolog']->newChannel('myaddon');

$logger->error('an error message', ['context' => 'foo']);
Refer to the documentation for more detailed usage instructions for Monolog.

You can create your own handler stack to customise how things are logged:
use Monolog\Logger;

$monolog = \XF::app()['monolog'];

$streamhandler = $monolog->stream(); // return our default stream handler for logging to a file (or create your own!)

/** @var Monolog\Logger $logger */
$logger = new Logger('myaddon');
$logger->pushHandler($streamhandler); // push our stream handler onto the handler stack
// you can apply any other customisations you like here as well by adding custom handlers, formatters or processors

$logger->error('an error message', ['context' => 'foo']);
Refer to Handlers, Formatters and Processors for more information.

The current version will add additional context including information about the web request which triggered the log, plus the userid and username of the currently logged in visitor. This will be configurable in later versions.
Tác giả
Lượt xem
First release
Last update
Bình chọn
0.00 star(s) 0 ratings

More resources from Admin