I want to log all JS errors in my project during the beta-testing time. Now I do it in the following way:
window.onerror = myErrHandler;
function myErrHandler(message, url, line)
{
$.ajax({
cache: false,
type: "post",
data: {error:message, url:url, line:line, brouser:navigator.userAgent},
url: "/Home/LogJavaScript/",
async: true
});
return true;
}
But this way couldn't help to get any information about call stack. So, information about errors inside jQuery or any other outer scripts couldn't help a lot.
Is there any way to improve such logging?
log() The console. log() method outputs a message to the web console. The message may be a single string (with optional substitution values), or it may be any one or more JavaScript objects.
Take a look at stacktrace.js, that should do the trick.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With