<p>Pretty sure you'd need to write a plugin that has a class that extends Yii's <a href="http://www.yiiframework.com/doc/api/1.1/CLogRoute" rel="nofollow">CLogRoute</a> and override the <a href="http://www.yiiframework.com/doc/api/1.1/CLogRoute#processLogs-detail" rel="nofollow">processLogs</a> method with your own logic.  Something like this:</p>

<pre><code>class StdErrRoute extends \CLogRoute
{
    public function processLogs($logs)
    {
        $strErr = fopen("php://stderr", "w");

        foreach($logs as $log)
        {
            fwrite($strErr, $log[0]);
        }

        fclose($strErr);
    }
</code></pre>

<p>}</p>

<p>Your plugin's <code>init()</code> method would register the route via <code>craft()-&gt;log-&gt;addRoute()</code>.</p>

CC BY-SA 3.0
2016-01-08T14:56:55.160Z
I've created a plugin out of this: https://github.com/nerds-and-company/loghelper
Bob Olde Hampsink
CC BY-SA 3.0
2014-10-15T17:42:25.683Z
2014-10-15T17:42:25.683Z
Brad Bell
<p>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?</p>

<config><logs>
Set logging path/file to use php://stderr
# Set logging path/file to use php://stderr

(Asked by: username_0 on 2014-10-15)

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?

**Tags:** config, logs

---

## 1 answers

### Answer by username_1 on 2014-10-15. Score: 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().

> **Comments:**
> **username_2**: I've created a plugin out of this: https://github.com/nerds-and-company/loghelper  

---

