Errorhandler Component In The Cconsoleapplication?

For our web-app we have followed the example in the Yii Error handler documentation ( and created a error action in SiteController. My question is about our console-app. I’d like to forward our console-app exceptions to a 3rd-party monitoring service (i.e. NewRelic) but I can’t think how to.


  • Somehow catch all CConsoleApplication exceptions, log to NewRelic and re-throw. But where can I catch them in a generic way?

  • Somehow define a errorHandler component in the CConsoleApplication?

  • Somehow extend CException into a ConsoleException which can log to NewRelic when it’s thrown?

  • Create a new CLogRouter class similar to CFileLogRoute but can also log to NewRelic when it notices an exception.

Is there a easy way to achieve this?

FYI: I found a solution - see