我尝试使用记录器出错,onerror函数我遇到了错误,但仅显示脚本错误, 如何解决呢? 导入此模块
import log4javascript from 'log4javascript';
componentDidMount() {
var Logger = log4javascript.getLogger();
var ajaxAppender = new log4javascript.AjaxAppender('http://localhost:5000/addFrontErrorLog')
ajaxAppender.setBatchSize(10); // send in batches of 10
ajaxAppender.setSendAllOnUnload();
Logger.addAppender(ajaxAppender);
onerror = (message, url, lineNumber) =>{
var errorMsg = "Console error- " + url + " : " + lineNumber + ": " + message
Logger.error(errorMsg);
console.log(errorMsg)
return true;
};
}
我得到类似
的输出Console error- : 0: Script error.