I’m triggering an error in my Symfony2 project like this:
trigger_error('message', E_USER_NOTICE);
How can I suppress this error, such that I don’t get a code 500 response but only get this notice logged with monolog?
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Using
trigger_erroris not the recommend way to trigger errors in Symfony2. The recommend way to trigger errors in Symfony2 is to use exceptions. In Symfony2 you can use the global exceptions and the exceptions created by the Symfony2 framework and even exceptions you created in a bundle:But if you want to log something to a file you can better use one of the
monolog.loggerservices (doctrine,event,profiler,request,router,securityortemplating). For more information, read the monolog documentation. You can also create your own Monolog logger, create a service and use that.