Monolog Logging Service 5.0.3

XF 2.1 / 2.2 / 2.3 Monolog Logging Service 5.0.3

Add-on xenforo 2

Ressources et modules complémentaires pour XenForo 2

Styles xenforo 2

Styles / Thèmes et apparence pour xenforo 2

Templates xenforo 2

Codes pour modifier les templates sur xenforo 2

Section Premium

Add-on et Styles pour membre Premium
  • ⚠️ Section Premium. Réserver aux Membres Premium ⚠️
Monolog Logging Service 5.0.3

XF 2.1 / 2.2 / 2.3 Monolog Logging Service 5.0.3

Catégorie Catégorie Add-Ons
Titre du sujet Titre du sujet Monolog Logging Service 5.0.3
Auteur de la discussion Auteur de la discussion laurent68
Date de début Date de début
Réponses Réponses 5
Affichages Affichages 318
Réaction Réaction 0
Dernier message par Dernier message par laurent68

laurent68

Fondateur

Staff
fondateur
Réputation: 100%
Discussions
5 084
Messages
13 297
Solutions
85
J'aime
8 133
Points
198
This XenForo 2.x addon adds logging functionality using the Monolog library from 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
bgl.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.

Télécharger V3.1.1 :

Version 4.0.0 implememts Monolog v2

Important to note is that the default date format in logs has changed for v2 - but for backwards compatibility I have reset the date format to that used by v1.
There is no new functionality in this version.

If you need Monolog v1 support - stay on the 3.x version of this addon - I will maintain that version for critical bugfixes.

Télécharger V4.0.0 :

Version 4.1.0 - XF 2.3 support :
- Added XF 2.3 support

Télécharger V4.1.0 :

Version 4.1.1 minor bugfix - assert admin permission on tools :
- Minor bugfix to explicitly enforce admin permissions on admincp tools.

Télécharger V4.1.1 :

Version 4.1.2 (2025-12-12)​

  • run enqueuePostUpgradeCleanUp during upgrades if we're running XF2.3+
  • latest composer dependencies
Télécharger V4.1.2 :

5.0.0 (2026-10-02)​

  • new: channel() returns a PSR-3 Psr\Log\LoggerInterface for an add-on's own log channel — type against that interface, not a Monolog class
  • deprecated: newChannel(), now an alias for channel(), and the static Hampel\Monolog\Helper\Log
  • removed: logger(), default(), stream() and visitor() — add or replace handlers and processors with the new hampel_monolog_setup code event instead
  • new: post log records to Slack through an incoming webhook — one message per request, sent with a short timeout, and a failed post never reaches the add-on that was logging
  • new: every option can be set in $config['monolog'] in config.php — file, email and slack sections, request_id, visitor, web and site — and the options page shows it as set there; handlers, processors and a file formatter add to the stack with no add-on
  • new: a minimum level per channel in config.php, so one add-on can be traced at Debug without turning up every other
  • new: Log File Format, Site Name and Add Request ID options; every record carries a request id, the web server's where it provides one
  • new: monolog:config and monolog:validate CLI commands — what is configured, and whether it works, with --unattended for a deploy gate
  • new: JSON records carry extra.site, extra.app and extra.schema
  • new: README guidance on choosing log levels, and on supporting 4.x and 5.x from another add-on
  • security: the log file option only accepts a path inside internal_data — a path outside it is ignored, and belongs in config.php
  • fix: email alerts were switched on by a fresh install until the options were saved — such installs stop emailing until email is enabled
  • fix: creating a log channel no longer builds XenForo's mailer, which could recurse with a mail add-on that logs
  • email is sent through XenForo's own mail system, on 2.2 and 2.3 alike
  • runs on Monolog 3 as well as 2
  • requires XenForo 2.2 and PHP 7.4

5.0.1 (2026-10-04)​

  • fix: email and Slack treated two different errors with the same message as a repeat, and suppressed the second — a repeat now also has to match the channel and, where the record has one, the exception or a fingerprint in its context
  • every message this add-on writes to the server error log now begins Monolog:

5.0.2 (2026-10-08)​

  • new: monolog:validate --strict exits 2 when there are warnings and no failures — for a monitor; 1 still means a failure, and without the flag nothing changes
  • monolog:validate warns when the log file, email and Slack are all off, where it used to report the empty logger as fine
  • monolog:validate checks that email and Slack can record what they have sent, and warns if not — without that record every repeat is sent again
  • every record monolog:validate and the Test Monolog page write carries probe: true in its context, so an alert over the log can leave them out

Version 5.0.3 (2026-10-09)​

- documentation changes only; no change in behaviour

Télécharger V5.0.3 :
 
Contenu similaire Les plus vues Voir plus
Retour
Haut Bas