I'm know PHP has error logs, but is there a way to record non fatal errors into a variable during the running of a script? I want to do this so I can perhaps enter in this information to a database, or send a formatted error report, rather than looking through error logs. Does PHP have a function that can do this?
Asked
Active
Viewed 183 times
0
-
You can define [custom error handlers](http://php.net/manual/en/function.set-error-handler.php), but it would be more advisable to create your well formatted output (or populate a database) independently from your running web application. Normally this is done by parsing the error logs and transforming them to whatever format you wish. You can checkout tools like [Graylog2](http://php.net/manual/en/function.set-error-handler.php) or [Logstash](http://logstash.net/) which bring very nice interfaces with them. – sthzg Apr 23 '15 at 12:55
-
I always thought that function did something slightly different, but now I can see how that could be used to log particular errors. Thank you. – Goose Apr 23 '15 at 13:31
1 Answers
0
This might not be the best solution:
Use error_log() to log all the errors in a particular file where all errors logged and at the last read that text file and insert into database.

Sanjay Kumar N S
- 4,653
- 4
- 23
- 38