Monolog Logging Service

[xF 2.0-FREE] Monolog Logging Service 3.0.0

No permission to download
  • Upgrade Your Account
    Hello Guest ! Upgrade your account to download any of our premium products Here.
    How to upgrade your account to download resources Learn More.
    Guest need to read through our rules and regulations Learn More.
    Important! Read your welcome message To know how to download.
  • This material is provided by the xFhat.com site for informational purposes only. Administration is not responsible for its contents.
Compatible XF 2.x versions
2.0
Additional Requirements
PHP 7.0+
This XenForo 2.0 addon adds logging functionality using the Monolog library from https://github.com/Seldaek/monolog

Features
  • Log to a file
  • Send logs via email
  • Emailed logs are deduplicated and buffered
  • Configure minimum logging levels for files vs email logging
  • Add extra visitor data to logs: user_id and username
  • Add extra web data to logs: current request URI, request method and client IP
  • Test tool included to verify that logs are being written to disk - go to AdminCP > Tools > Checks and tests > Test Monolog



Usage Instructions

By default, this addon will log events to a file called internal_data/monolog.log - this is configurable.

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

PHP:
use Monolog\Helper\Log;
Log::info('an info message', ['context' => 'foo']);
Log::error('an error message', ['data' => 'bar']);
However, it is recommended that you create your own channel for your addon to make it easier to filter log entries:

PHP:
$logger = \XF::app()->get('monolog')->newChannel('myaddon');
$logger->warning('a warning 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:

PHP:
use Monolog\Logger;

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

/** @var Monolog\Logger $logger */
$logger = $monolog->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->critical('a critical message', ['context' => 'foo']);
Refer to Handlers, Formatters and Processors for more information.
Reactions: dbuzz and k3ndyhai
Author
J0ker
Downloads
3
Views
14
First release
Last update
Rating
0.00 star(s) 0 ratings

More resources from J0ker

Share this resource

Latest updates

  1. v3.0.0 new addon_id

    I am changing the structure of the addon_id I use for my addons - so this version is a...
  2. New configuration options; email support

    added helper class for logging added support for emailing log messages added configuration...