Remove Yii/php Addtions To Logged Message

At which point (and why?) my logged message:

Test Message

is turned into:

Test Message

in C:\XAMPP\path\protected\controllers\SiteController.php (107)

in C:\XAMPP\path\htdocs\index.php (42)

How to get rid of this addition or how to log only what, I really want to log?

Is there a switch/flag in log route configuration to handle this or do I have to overwrite processLogs() or even entire CLogger class?

$log[0] = strstr($log[0], "\n", true)

I tried to read about CLogFilter, but it seems to be unrelated, as I see there only options for adding user, seession and variables to the message. I don’t see anything about adding path to file message.

EDIT: I want to get rid of this addition, because I already record request / URL / route in a separate database table, with implementation of this cool article. [i]Beside, I don’t like, when anything is trying to do something more, than expected. If I log “Test message”, a want “Test message” to be logged and nothing else.

[/i]EDIT2: I noticed, that my own (manual, custom) messages are recorded with “in path/file” part added in second and following lines (as in example above), while system, error message (i.e. exceptions) are recorded with “in…” part added to first line of message body. So, even filtering proposed by me won’t work. Why, this is so strange?


Recently I also want to remove the addition and I able to do it by extends CFileLogRoute and remove the addition manually by using regex, for example

class MyLogRoute extends CFileLogRoute


	protected function formatLogMessage($message, $level, $category, $time)


		$message = trim(preg_replace('/^in [^(]+\(\d+\)$/m', '', $message));

		return @date('Y/m/d H:i:s',$time)." [$level] [$category] $message\n";




I cannot find where they start to adding path and I don’t want to dig it further so instead I do this.

Hope this will help you.

It turned out, that these additions are added only, when you have set YII_DEBUG to TRUE and YII_TRACE_LEVEL to something else than 0. I.e. It happens only in debug mode, in development environment.

When you run your application in production mode (without YII_TRACE_LEVEL and YII_DEBUG set), there will be no additions like that. Just the pure message, you log.

So, for me, this ends the case.

BTW: I also tried with extending base class. Results were partially acceptable. But, as soon, as I learnt above, I reverted all these changes and went back to using core class.