Yii 1.1: Logging to Heroku's logs from Yii

1 follower

In order to get your Yii logs into Heroku's logs, you have to work a little bit of magic. You'll need to modify the boot.sh script and add the following two lines:

touch /app/apache/logs/app_log
tail -F /app/apache/logs/app_log &

This will set up the log and tail it so that when you request "heroku logs", this log is included.

Then, your component looks like this:

class CHerokuLogRoute extends CLogRoute
    public function processLogs($logs)
        $STDOUT = fopen("/app/apache/logs/app_log", "a");
        foreach($logs as $log) 
            fwrite($STDOUT, $log[0]);

Any questions or issues, please refer to the github page at https://github.com/aarondfrancis/yii-CHerokuLogRoute

For other Yii & Heroku how-to's, check my blog at http://aaronfrancis.com/blog/?tag=Yii

Be the first person to leave a comment

Please to leave your comment.

Write new article
  • Written by: aarondfrancis
  • Category: How-tos
  • Yii Version: 1.1
  • Votes: +2 / -1
  • Viewed: 6,233 times
  • Created on: May 4, 2013
  • Last updated: May 21, 2014
  • Tags: heroku, Logging