4

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?

4

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().

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.