Advanced Logging in Yii

Here are some nice examples of using the logging facilities in Yii

                                    // you can include more levels separated by commas
                                'levels'=>'trace, info, error, warning, vardump',
                                    // categories are those you used in the call to Yii::trace
                                // This is self-explanatory right? but also works in Chrome!
                                'levels'=>'trace, info, error, warning, vardump',
                          /*  array(
                                'levels'=>'error, warning',

I use a function to create a trace log, defined in my base index.php as follows:-

function fb($what,$where='fb.somewhere'){
     if ($where=='trace')
         Yii::log($what, 'info', 'application');

In this way, I just need to add "fb ($variable, "optional category or comment");" in my code!

Did you know you can hire me?

I take on projects of all sizes. From Consulting to large Development Projects.

If you're starting a new Yii project and would like some help to get setup and running or you need some help with a particular module or you just need someone to develop the whole dang thing, then just ask ...

Beginning Yii ...

I'm very excited about a new Yii Training course that has just been published.

The course is designed for anyone wanting to learn Yii, whether new to frameworks or converting from another.

Eight chapters, each having five videos of between 3 and 5 minutes, take you through the basics of the Yii Framework, building a web application step-by-step.

Save 40% - introductory offer $20.99 / £13.19 / €16.19 / A$20.99

Leave a Comment