How Do I Get The Profiling Information Logged Rather Than Shown On The Page?

I have tried profiling, but to my astonishment, the profile information is shown in the web page itself, even though I have no CWebLogRoute enabled.

As far as I can understand from the documentation, in order to use profiling (be it generic performance profiling or SQL query performance profiling by enabling db->enableProfiling), I need to put a CProfileLogRoute in the logger. However, I can’t seem to find a way to have this information logged through the CFileLogger I already use rather than shown in the web page itself.

I must be missing something. It can’t be true that the only available option for profiling is to have it shown on the web page (so you can’t do profiling on a page that is up an running).

How do I accomplish that?

You just have to specify it properly in your config file:




        'log' => array(

            'class' => 'CLogRouter',

            'routes' => array(

                array(

                    'class' => 'CFileLogRoute',

                    'levels' => 'profile',

                    'enabled' => true

                ),

            ),

        ),



Can you show section ‘log’ from your config file? Perhaps I’ll be able to tell you why profiling information are still shown on webpage when you haven’t it enabled.

Oh, I see, thanks!

That should be better documented.

I was using CProfileLogRoute instead, as it is the only option mentioned in the Definitive Guide:

http://www.yiiframework.com/doc/guide/1.1/en/topics.logging#performance-profiling


array(

                    'class'=>'CProfileLogRoute',

                    'report'=>'summary',

                    

                ),

(besides my CFileLogRoute)

The reference of YiiBase::beginProfile() and endProfile() doesn’t say a word about how you can route the results, and the reference of CFileLogRouter doesn’t specify the valid values for ‘levels’ (or the standard ones, as I guess one can add his own arbitrary levels maybe).

Now just change


array(

                    'class'=>'CProfileLogRoute',

                    'report'=>'summary',

                    

                ),

into


array(

                    'class'=>'CProfileLogRoute',

                    'report'=>'summary',

                    'enabled' => false  

                    

                ),

to get rid of this webpage logging.

Of course! ;)