awflogroute AWFLogRoute - Ajax Web File Log Route class

  1. Requirements
  2. Usage
  3. Options
  4. Styling
  5. Changelog
  6. Discussion

This log route tries to solve and add the missing part of the CWebLogRoute.

CWebLogRoute is a great way to get interesting information on the web page but it has it's drawbacks. First of all it display the log every time and it outputs the log on the end of the generated web page and this can make more trouble than good.

The log is placed after the ending html directive, this way it makes non valid HTML markup, and by looking at the web page source you can see the whole long log appended at the end. This troubles me many times while developing. When I want to see the JS code generated by Yii, by going to the end of the file I expect to see the JS code but instead there is the whole log that I need to scroll upward to find the JS code.

Two things I miss most from CWebLogRoute is the possibility to decide when I want to see the log and to see logs from an AJAX call.

That's how the idea of the AWFLogRoute was born.

The main points of this log route is to have valid HTML syntax, clean HTML, show logs only on request and the possibility to show logs for AJAX requests.

When this route is used, the only code added to the web page is a small JS code that generates a button that is used to display the application log. No log data is on the web page, the log is instead saved on a file on the server. In that file there is just the log of the last processed request. If the developer needs to see the application logs for the just executed request, he just needs to click the "Load Application Log" button. At that time an ajax request is executed that gets the logs from the log file and the log is shown on the web page. By clicking "Re-Load Application Log" the log is reloaded with the logs from the last processed request. This can be used after any AJAX request like CGridView pagination, filtering or sorting.


  • jQuery 1.7 (the new "on" method is used)
  • developed on Yii 1.1.9 that has jQuery 1.7 as part of the core


  • create a new sub-folder AWFLog in the /protected/components folder
  • download the ZIP file and place the content (2 php files) in the new folder (/protected/components/AWFLog)
  • configure your application to use this route by modifying the config file (/protected/config/main.php)

Config example:

'log' => array(
	'class' => 'CLogRouter',
	'routes' => array(
			'class' => 'application.components.AWFLog.AWFLogRoute',

Update v.0.3

Now it's possible to set the alias for the controller of this extension. This is useful if you place the extension in a folder other than /protected/components/awflog.

For example if you place this extension in the /protected/extension/awflog folder than you can use this settings:

'log' => array(
	'class' => 'CLogRouter',
	'routes' => array(
			'class' => 'ext.AWFLog.AWFLogRoute',
			'controllerAlias' => 'ext.AWFLog',


  • logPath - the directory where the log file will be stored. Defaults to application runtime path.
  • logFile - name of the log file. Defaults to 'awflogroute.log'.
  • controllerAlias - the directory alias where the AWF Log controller is located. Defaults to 'application.components.AWFLog.AWFLogController'.


The generated buttons and log content can be styled with custom CSS. These are the used IDs

  • AWFLogBtn - DIV that holds the 2 buttons
  • AWFLogBtnShow - "Load Application Log" button
  • AWFLogBtnHide - "Remove Application Log" button
  • AWFLogData - DIV that holds the log data


  • 29.02.12 15:30 - version 0.3
    • added controllerAlias attribute (see above the update v.0.3 for more info)
  • 28.12.11 16:00 - version 0.2
    • added data parameter when enableCsrfValidation is used
    • added details of the request (uri, type and AJAX)
  • 22.12.11 23:40 - version 0.1
    • fixed JS code rendering
    • now it's possible to manually add the buttons and/or the data container
  • 22.12.11 15:00 - initial release


For discussion about this extension follow this forum thread.

9 0
Yii Version: 1.1
License: BSD-2-Clause
Category: Logging
Developed by: Maurizio Domba Cerin
Created on: Dec 22, 2011
Last updated: 9 years ago


show all

Related Extensions