Not able to see the log file in Yii

11,081

Solution 1

May be something wrong name with your log class CLoCFileLogRoutegRouter. It should be CLogRouter

'log' => array(
    'class' => 'CLogRouter',
        'routes' => array(
            array(
                'class' => 'CFileLogRoute',
                    'levels' => 'error, warning, info',
                    'categories'=>'system.*',
                ),

Solution 2

Even though the question is already answered

Please consider that Yii writes logs after the main script is ended, So if you terminate your script using die() command, you never let Yii write it down. To avoid such problems you should terminate the script using Yii::app()->end() command.

For more information see here

Solution 3

You are configuring your log to only log messages related to 'error, warning, and info',

And you are trying to Log, "trace" (Yii::trace) and "profile" levels, thats why you are not getting anything.

Also: dont try to log "profile" things on you own, there are specific methods for that, namely Yii::beginProfile() and Yii::endProfile, read more about profiling at the yii guide

Solution 4

This is most likely a permissions problem. Is the runtime directory writable by your web server (Apache)?

Share:
11,081
Arfeen
Author by

Arfeen

A PHP/NodeJS developer who started from PERL ...Work on LAMP/WAMP

Updated on June 23, 2022

Comments

  • Arfeen
    Arfeen almost 2 years

    I am not able to see the log files in Yii framwork. By default it saves in "protected/runtime". Here is my config in main:

    'log'=>array(
                'class'=>'CLoCFileLogRoutegRouter',
                'routes'=>array(
                    array(
                        'class'=>'CFileLogRoute',
                        'levels'=>'error, warning, info',
                        'categories'=>'system.*',
                    ))),
    

    and this is how I'm logging:

    Yii::log("Index Checkout", "profile", 'system.web.CController');
    Yii::trace('IndexCheckout', 'system.web.CController');
    

    Not getting any error but can't find any log file.

    Any idea ? Thanks.