I'm rethinking our Craft environment/workflow. My idea is to accommodate disposable and/or multiple container (or server) environments. As a result I want to use log aggregation apps like papertrail, logstash, etc to consolidate and investigate logging across multiple servers. They recommend logging to php://stderr. Is this possible? What approach would you take to override the apps log route?
Pretty sure you'd need to write a plugin that has a class that extends Yii's CLogRoute and override the processLogs method with your own logic. Something like this:
class StdErrRoute extends \CLogRoute
{
public function processLogs($logs)
{
$strErr = fopen("php://stderr", "w");
foreach($logs as $log)
{
fwrite($strErr, $log[0]);
}
fclose($strErr);
}
}
Your plugin's init()
method would register the route via craft()->log->addRoute()
.
-
2I've created a plugin out of this: github.com/nerds-and-company/loghelper – Bob Olde Hampsink Jan 8 '16 at 14:56