views:

68

answers:

2

I want to know how I can display E_ERROR error messages to the screen but write E_ALL error messages to the error log, we currently use the error_reporting() in our app index page so we can change error reporting without the need to constantly restart the web server, but it seems that this (or perhaps the way it's meant to work) means that we only log errors that we see on the screen.

Is there a way to log and display different levels of errors?

Cheers!

+1  A: 

You could make a custom error handler, and in your error handler check if the error is an E_ERROR; if so, print it out. Then log the error, regardless of whether it is an E_ERROR or not.

If you're not familiar with custom error handling, the PHP manual has a good example on how to use an error handler to do different things depending on the nature of a PHP error.

BoltClock
Many thanks, I'll have a look into this and get back to you :-)
ILMV
Looking at the PHP manual it would appear this this does not work for the following error types `E_ERROR, E_PARSE, E_CORE_ERROR, E_CORE_WARNING, E_COMPILE_ERROR, E_COMPILE_WARNING, [and sometimes] E_STRICT`, so this method won't work for me. It's a shame because it seemed like it was exactly what I wanted. Do you know of another method perhaps? Thanks for the suggestion anyway :-)
ILMV
Everybody loves a good random downvote.
BoltClock
+3  A: 

You should use such library as Lagger

StanlyQ
Thanks! I'll take a look at it.
ILMV