JavaAcript AJAX远程记录器 [英] JavaAcript AJAX remote logger

查看:136
本文介绍了JavaAcript AJAX远程记录器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的工作不具备日志输出支持平台上的JavaScript应用程序,不允许记录器的输出打开新窗口,并没有任何类似Firebug或Safari调试器就可以了...

I am working on JavaScript application on the platform which does not have support for log output, does not allow opening new windows for logger output and has nothing like Firebug or Safari debugger on it...

到目前为止,我用的是浮动LT; D​​IV> 的z-index 2 ,我记录的文字里面,但这是不够的。我要寻找一些轻量级的JavaScript JSONP记录器和一些PHP或Tomcat服务器对应...

So far I was using the floating <div> on z-index 2 and I logged the text inside, but this is not sufficient. I am looking for some lightweight JavaScript JSONP logger and some PHP or Tomcat server counterpart...

谢谢 斯登

推荐答案

我最近偶然发现了N. Zakas这个presentation,并实现了该技术有解释。这是很简单,但恕我直言非常有效

I recently stumbled upon this presentation of N. Zakas, and implemented the technique explained there. It is quite simple but IMHO very effective

<一个href="http://www.slideshare.net/nzakas/enterprise-javascript-error-handling-$p$psentation">http://www.slideshare.net/nzakas/enterprise-javascript-error-handling-$p$psentation

这个想法是简单地发出调用服务器端组件(我用的是.NET处理程序,但它可能是一个PHP文件中。)这需要一些参数,记录参数值,并返回一个1x1的图像流回来。我最喜欢的是,有没有必要让阿贾克斯的所有呼叫。

the idea is to simply issue a call to a server side component (I used a .net handler but it could be a php file as well) which takes some param, log the param values and returns a 1x1 image stream back. What I like the most is that there's no need to involve ajax calls at all.

从presentation的code是如下:

The code from the presentation is as follows:

    function log(severity, message) {
      var img = new Image();
      img.src = "log.php?sev=" + encodeURIComponent(severity) +
      "&msg=" + encodeURIComponent(message);
    }

    log(1, "something bad happened");

这篇关于JavaAcript AJAX远程记录器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆