Logging to Heroku's logs from Yii

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]);
        fclose($STDOUT);
    }
}

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

1 0
1 follower
Viewed: 6 465 times
Version: 1.1
Category: How-tos
Written by: aarondfrancis
Last updated by: aarondfrancis
Created on: May 4, 2013
Last updated: 4 years ago
Update Article

Revisions

View all history

Related Articles