I would like to use set of custom Exception classes in my project based on silex (silex.sensiolabs.org) framework. I prefer to write an error message into log file in function "__construct". Is there a way to access to $app['monolog'] inside __construct function of MyException class? I think what to use an $app as constructor parameter or as global variable is not elegant way.
class MyException extends Exception
{
public function __construct($message = '')
{
parent::__construct($message);
//how to do?
$app['monolog']->addError($message);
}
}