log4javascript

Internet Explorer的“控制台”是未定义的错误

可紊 提交于 2020-02-25 20:59:32
我正在使用Firebug,并且有一些类似的语句: console.log("..."); 在我的页面中。 在IE8(可能也是早期版本)中,我收到脚本错误,提示“控制台”未定义。 我尝试将其放在页面顶部: <script type="text/javascript"> if (!console) console = {log: function() {}}; </script> 仍然我得到错误。 有什么办法摆脱错误? #1楼 在IE9中,如果未打开控制台,则此代码: alert(typeof console); 将显示“对象”,但是此代码 alert(typeof console.log); 将抛出TypeError异常,但不返回未定义的值; 因此,保证版本的代码将类似于以下内容: try { if (window.console && window.console.log) { my_console_log = window.console.log; } } catch (e) { my_console_log = function() {}; } #2楼 if (typeof console == "undefined") { this.console = { log: function() {}, info: function() {}, error: function() {

Get the class function name within itself

梦想的初衷 提交于 2020-01-03 19:08:31
问题 I'm trying to setup logging across my typescript program, using log4javascript . However I have no idea how to retrieve the function names using reflection (rather than typed manually). Ideally I want to emulate what I do in C# : public class Foo { private static readonly log4net.ILog logger = log4net.LogManager.GetLogger(typeof(Foo)); public Foo() { } public FooMethod() { try { logger.Logger.Log(this.GetType(), log4net.Core.Level.Trace, "Entering" + MethodBase.GetCurrentMethod().Name, null);

Chrome/Safari: how to open the same window from different tabs or windows

限于喜欢 提交于 2019-12-25 18:13:05
问题 In a web application, I have an optional popup window into which logging content is being loaded. This window is opened via Javascript using window.open() . The users typically have multiple tabs of the application open and my intention is to always reuse the same popup window (if currently open), no matter from which tab they trigger the popup. To do so, I use code similar to this to open the popup: <script> function myFunction() { var myWindow = window.open("popup.html", "my_popup", "width

Override console.log (or any function in general): Is there a proper way to do this? [duplicate]

隐身守侯 提交于 2019-12-11 19:35:15
问题 This question already has answers here : js override console.log if not defined (7 answers) Closed 6 years ago . I find myself doing this quite often both on the browser and in node.js and it's about time I came up with a proper way to do this without debugging it for a while each time. Here's what I'm currently working on (this is node.js): var log4js = require("log4js"); log4js.loadAppender('file'); log4js.addAppender(log4js.appenders.file('log.log')); var logger = log4js.getLogger();

Log4JavaScript server-side receiving

青春壹個敷衍的年華 提交于 2019-12-08 02:45:02
问题 I'm trying to use Log4Javascript to send client-side errors to the server where results can then be written to file. I'm using the AjaxAppender to try to send the data to the server. I started with a simple "Hello world" to see if I can figure out how to receive error messages because the documentation literally says "no server-side code is provided". Basically, I'm relatively new to this. A good Java programmer, HTML, CSS, Javascript, etc. But I've recently dived into the world of JSP and I