PHP monitor for all my apps' and sites' errors, logs, etc
What I'd like
I'd like to have an internal web app in PHP where I can look at all my errors, logs, etc., from all my apps and sites.
Let me paint a picture to explain: I'd like to go to something like monitor.thecompany.com and I will see that there was an error uploading a file on client1.com and that a new user was registered at client2.com.
Internals
I imagine that I would call a function in my apps and sites (something like send_to_monitor($type, $title, $description)
), which would send the data to this monitor service. This service would then save the data to the database and later display all the errors and logs for me in a page (e.g. monitor.thecompany.com).
Questions
- Is there a solution for this already? I'm a coder so this is not that important for me, but just in case. And if there is, I only want something that can be easily imp开发者_JAVA技巧lemented in my apps.
- What would be the API for the service? How would I do that? RESTful (how would I implement that)? I don't need exact code, just pointers in the right direction.
- How would I call this service from the client app?
- What about security? I'm not that worried that someone will read my logs, but if the service is completely open someone could throw new errors in.
What about easy function that would save your logs to one central database?
function monitor($type, $title, $description){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"http://your.error/and_log/handler.php");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "type=".$type."&title=".$title."&desc=".$description."&password=6as5d465as4df987498*/*/*+§§§");
curl_exec ($ch);
curl_close ($ch);
}
http://your.error/and_log/handler.php will proccess data and save it
There's nothing easier
There is a plugin that you can use in your PHP to monitor the logs live on the web. Try this :
http://sourceforge.net/projects/webtailx/files/webtailx/
Netuts+ wrote an article on emailing error reports. You could use a Gmail address so your inbox doesn't get polluted and you have access to special labels, searches, and filters.
Another option is an AJAX powered monitor. Perishable Press wrote an article on building one for Wordpress that you could easily adapt for your site.
If you want to push your own messages use trigger_error()
.
精彩评论