Logging to Heroku's logs from Yii

You are viewing revision #3 of this wiki article.
This is the latest version of this article.
You may want to see the changes made in this revision.

« previous (#2)

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: 10 277 times
Version: Unknown (update)
Category: How-tos
Written by: aarondfrancis
Last updated by: aarondfrancis
Created on: May 4, 2013
Last updated: 9 years ago
Update Article

Revisions

View all history

Related Articles