PHP monitor for all my apps' and sites' errors, logs, etc

巧了我就是萌 提交于 2019-12-22 13:05:06

问题


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

  1. 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 implemented in my apps.
  2. 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.
  3. How would I call this service from the client app?
  4. 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.

回答1:


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




回答2:


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/




回答3:


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().



来源:https://stackoverflow.com/questions/6897668/php-monitor-for-all-my-apps-and-sites-errors-logs-etc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!