Page MenuHomePhabricator

Look at adding Log implementation for greater visibility on Civi logging
Open, Needs TriagePublic


Currently Civi logs to ConfigAndLog dir which we have lower visibility on - more visibility came up in
Relates to

From Tim

broadly/generally/from an ext? implement hook_civicrm_container and replace the definition of the psr_log service
11:09 AM
the stock definition is $container->setDefinition('psr_log', new Definition('CRM_Core_Error_Log', []));
eileen profile image
11:09 AM
cool thanks
eileen profile image
11:14 AM

@totten can we send it different places - ie Civi::log('important_stuff_for_syslog') to go to a different place than the other stuff?
totten profile image
11:16 AM
imho, the best option is to put in something like Monolog.
in that model, there's one "log" instance/service, but you can add/remove a bunch of rules for how it routes messages
11:16 AM
e.g. you cna put in a rule that says "all critical messages are sent to syslog"
11:17 AM
"all debug messages are sent to a bespoke log file"
11:19 AM

there is an argument to made for Civi::log($channelName) as part of DX.
if the stock impl were based on monolog, and if one wanted to create new channels on the fly, then the impl of the Civi::log() could just wrap withName(), e.g.
public static function log($channelName = NULL) {

$log = Civi::service('psr_log');
return $channelName ? $log->withName($channelName) : $log;


Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptTue, Oct 15, 10:47 PM