Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-01-08T14:56:55.160Z
Answers.Text: I've created a plugin out of this: https://github.com/nerds-and-company/loghelper
Answers.UserDisplayName: Bob Olde Hampsink
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-10-15T17:42:25.683Z
Answers.LastActivityDate: 2014-10-15T17:42:25.683Z
Answers.UserDisplayName: Brad Bell
Body: <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>
  
Tags: <config><logs>
Title: Set logging path/file to use php://stderr
ThreadText: # 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](http://www.yiiframework.com/doc/api/1.1/CLogRoute) and override the [processLogs](http://www.yiiframework.com/doc/api/1.1/CLogRoute#processLogs-detail) 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  
  
  ---
  
  