Reputation: 633
Well...I do know it's good to log errors when the website is in production and error reporting is off. But what should I actually log? I can't log all errors, so I should to choose some most errors-probable places in the code and call the function with some message to log this. Should I use try-catch to do this? And is it actually the best way to do this?
Upvotes: 0
Views: 95
Reputation: 522041
You should have several levels of error severity, all of which are handled differently:
You intersperse your app with all these different types of errors/events. Notices and up should be logged, errors and up should be logged in detail (dump the system status into a separate file) and for critical errors and up somebody should be automatically notified.
See https://github.com/Seldaek/monolog for a good component which can help you do this.
Upvotes: 5