Monolog Logging Service

XF2 Addons Monolog Logging Service 4.0.0
This XenForo 2.x addon adds logging functionality using the Monolog library

Compatible versions
2.1, 2.2
This XenForo 2.x addon adds logging functionality using the Monolog library from https://github.com/Seldaek/monolog

Notes

v3.x of this addon uses Monolog v1
v4.x of this addon uses Monolog v2

There is currently no difference in functionality between the two versions other than the version of Monolog used.

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

1516192724416.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:

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.
Disable VPN/Proxy for a Better Experience
FateKid
Author FateKid
Level
11
5,910 pts
4.0.0 Version
0 Downloads
196 Views
Published
Updated
0.00 star(s) 0 ratings Average Rating (0)

More files from FateKid

Customize Your XenForo 2 Community

Monolog Logging Service provides ultimate customization to your XenForo 2 community website! Enjoy powerful features that make your site stand out. Combine this add-on with XenForo 2 styles from our site and kickstart your online community now.

Why Download Our XenForo 2 Add-ons?

  • Easily enhance the quality of your XenForo online community.
  • Expand your XenForo 2 functionality with thousands of unique options.
  • Create unbelieveable user-experiences with advanced features.

Explore Other Resources

Are you looking for something different? Explore our thousands of unique and special XenForo 2 add-ons, available to download right now. FateKid shared this wonderful resource to you for free, so remember to share your appreciation by liking the resource and reviewing it.

Get started today and make your next project truly unique.

Top Bottom