Resource icon

xF2 Add-on Monolog Logging Service 4.0.0

No permission to download
Compatible XF Versions
  1. 2.1
  2. 2.2
This XenForo 2.1 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
1569953477453.png


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:
Code:
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.
Author
AnimeHaxor
Size
237.5 KB
Extension
zip
Downloads
6
Views
1,395
First release
Last update

More resources from AnimeHaxor

Latest updates

  1. v4.0.0 update - Monolog v2

    v4 implememts Monolog v2 Important to note is that the default date format in logs has changed...
  2. v3.1.1 compatibility with Swiftmailer v6 in XF 2.2

    XenForo v2.2 moved to Swiftmailer v6 - this addon release maintains compatibility across both XF...
  3. v3.1.0 updates

    updates for XF 2.1

Similar resources

[OzzModz] User IP Logging Bypass Permission Admin
0.00 star(s) 0 ratings
Downloads
0
Updated
[KL] Notification Service Framework (NSF) AnimeHaxor
A framework for integrating various 3rd party notification services.
0.00 star(s) 0 ratings
Downloads
16
Updated