20.11.2014 Views

O Guia Definitivo do Yii 1.1

O Guia Definitivo do Yii 1.1

O Guia Definitivo do Yii 1.1

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

To use message routing, we need to install and preload a CLogRouter application<br />

component. We also need to configure its routes property with the log routes that we want.<br />

The following shows an example of the needed application configuration:<br />

array(<br />

......<br />

'preload'=>array('log'),<br />

'components'=>array(<br />

......<br />

'log'=>array(<br />

'class'=>'CLogRouter',<br />

'routes'=>array(<br />

array(<br />

'class'=>'CFileLogRoute',<br />

'levels'=>'trace, info',<br />

'categories'=>'system.*',<br />

),<br />

array(<br />

'class'=>'CEmailLogRoute',<br />

'levels'=>'error, warning',<br />

'emails'=>'admin@example.com',<br />

),<br />

),<br />

),<br />

),<br />

)<br />

In the above example, we have two log routes. The first route is CFileLogRoute which<br />

saves messages in a file under the application runtime directory. Only messages whose<br />

level is trace or info and whose category starts with system. are saved. The second route<br />

is CEmailLogRoute which sends messages to the specified email addresses. Only<br />

messages whose level is error or warning are sent.<br />

The following log routes are available in <strong>Yii</strong>:<br />

• CDbLogRoute: saves messages in a database table.<br />

• CEmailLogRoute: sends messages to specified email addresses.<br />

• CFileLogRoute: saves messages in a file under the application runtime directory.<br />

• CWebLogRoute: displays messages at the end of the current Web page.<br />

• CProfileLogRoute: displays profiling messages at the end of the current Web page.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!