steveo225
steveo225

Reputation: 11882

Proper and convenient error handling and logging using PHP

I have 3 domains that belong to the same organization and I am trying to come up with a proper and convenient means of handling errors across all sites.

For starters, my sites are designed as such:

  1. Error reporting is set to ALL
  2. Custom error handler throws exceptions
  3. All code (except the page header and footer) are wrapped in a try/catch
  4. On exception, a simple message is displayed to the user and the exception is logged to file (in a private folder)

This works fine, except that I have 3 websites to check for errors, and I often forget about 2 of them. The third shows the errors when a user logs in as administrator (as the file is locally available). All 3 sites are administrated via an admin portal on the main site.

I thought about logging the errors to database so the main site could show everything, but this breaks if it is a database error (such as temporarily unavailable).

Any suggestions would be appreciated.

Upvotes: 0

Views: 56

Answers (1)

Kyle
Kyle

Reputation: 1733

Why not just put the errors in a file in a JSON array or something similar, and then make that file externally available for the appropriate sites?

Upvotes: 1

Related Questions