Logging and using the context information
Sometimes a log message is not enough to fix an error. For example, when you are following best practices by developing and testing an application with all possible errors reported, you can get an error message. However, without the execution context, it is only telling you that there was an error and it is not clear what actually caused it.
For our example, we will use a very simple and poorly coded action that just echoes Hello, <username>! where the username is taken directly from $_GET.
Getting ready
Configure PHP to use the most strict error reporting. In
php.ini, replace theerror_reportingvalue with-1. This change requires restarting the server.Set up a fresh Yii application by using
yiic webappas described in the official guide.
How to do it...
Carry out the following steps:
First, we will need a controller to work with. Therefore, create
protected/controllers/LogController.phpas follows:<?php class LogController extends CController...