log and trace level with category

Hi all,

I am wondering if it is currently possible to specify the trace level on a certain category?

For example:

Yii::log(‘Mailing for blabla started’, ‘info’, ‘mailing’);

I do not necessary want to have a trace on that particular category (If trace level is set to 3 by default). Is there any way to do that?


hum anyone got the same issue? :)

Check the properties of Clogrouter

I cant see anywhere how to achieve what I want to do in the CLogRouter doc page.

Basically when I log something with a particular category, I do not want to have a stack trace (if it set to 3 levels), I just want one line like:

"Starting job blabla at 13:30"

"Processing data 1 at 13:31"

etc etc

You can route the cateagory you want to cfilelogrouter, so you will get a log file for only one category.

Yeah I have already done something similar to:




'levels'=>'trace, info',





So all of my

Yii::log('blabla', 'info', 'cron');

are going to the right file, the issue is that when I call Yii::log(), it writes 3 lines (the number of the stack level set), and I just want one line to be written. (if that makes sense?)

You can control that with YII_TRACE_LEVEL constant. See here:


Hello Mike,

Thanks for your answer, I tried to set the constant YII_TRACE_LEVEL to 0 before the call to Yii::log() for that particulary category, but as it set in the bootstrap (index.php) and as I still want to log error with a trace level of 3 it didnt work.

So I had to build my own class to log it which is quite confusing really.

Did you read the guide carefully? You can’t change YII_TRACE_LEVEL, it’s a constant:


Sorry, not sure my issue has been understood.

What I am trying to do is logging some information for a particular category without having a trace level. But on the other hand continue to log normal error, warning with a trace level :)

So it sounds like this is not possible currently.

has a solution for this been found yet? I also want to include a stack trace while in development mode on most but not all log-messages.

IMHO this should not be a constant, but a setting of CLogRoute.

I just ended up writing my own class to do so and problem solved.

Shame though that such functionality is not here on Yii )

Sigh. I have been hearing I gave up a bit too often.

Okay, thanks anyway! Guess i’ll just ignore those messages till it is ready for production.