从Google Chrome导出Javascript控制台日志 [英] Export Javascript Console log from Google Chrome

查看:1393
本文介绍了从Google Chrome导出Javascript控制台日志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



如果没有,任何人都可以建议一种很好的方式来诊断客户端的JavaScript问题机?我无法在本地复制问题,尽管设置了相同的环境。

解决方案

步骤1:添加一堆console.log语句将帮助诊断您的问题



步骤2:添加逻辑以重新定义您的客户端系统上的console.log,以便实际上将其参数保存到窗口.log(或其他),而不是实际登录到控制台。

  window.log = [] 
控制台= console || {log:function(x){window.log.push(x);}}

步骤3:添加一个onUnload处理程序,它将一个AJAX请求发送到服务器,其window.log的内容是其参数之一。



步骤4:利润! ; - )



这个系统的一个额外的好处是(一旦你设置好了),你可以不加选择地使用console.log,以及你是否在你的开发环境或者你的现场环境会做正确的事情。


Is there any way to export messages logged to the javascript console in Google Chrome?

If not, can anyone suggest a good way to diagnose javascript problems on a client's machine? I have not been able to replicate the problems locally, despite setting up an identical environment.

解决方案

Step 1: Add a bunch of console.log statements that will help diagnose your issue

Step 2: Add logic to re-define console.log on your client's system so that it actually saves its arguments to window.log (or whatever) instead of actually logging them to the console.

window.log = []
console = console || {"log":function(x) {window.log.push(x);}}

Step 3: Add an onUnload handler which fires of an AJAX request to your server with the contents of window.log as one of its parameters

Step 4: Profit! ;-)

An added bonus to this system is that (once you have it setup) you can use console.log indiscriminately, and whether you're in your dev environment or your live environment it will do the correct thing.

这篇关于从Google Chrome导出Javascript控制台日志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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