Skip to content

Instantly share code, notes, and snippets.

@picodotdev
Last active December 15, 2015 20:41
<!DOCTYPE html>
<html>
<head>
<title>¡Html Error!</title>
<script type="text/javascript" src="js/require.js" data-main="js/main"></script>
<script type="text/javascript">
requirejs.config({
shim: {
'log4javascript': {
exports: 'log4javascript'
}
}
});
</script>
</head>
<body>
<h1>¡Html Error!</h1>
</body>
</html>
require(['log4javascript'], function(log4j) {
var log4j = log4javascript;
var ajaxAppender = new log4j.AjaxAppender('http://localhost:8080/html-error/ajaxAppender');
var ajaxLayout = new log4j.PatternLayout('%d{HH:mm:ss} %-5p %c %m%n');
ajaxAppender.setLayout(ajaxLayout);
ajaxAppender.setThreshold(log4j.Level.INFO);
log4j.setEnabled(true);
var log = log4j.getLogger('es.com.blogspot.elblogdepicodev.log4javascript');
log.addAppender(ajaxAppender);
// Capturador de errores javascript
window.onerror = function(message, url, linenumber) {
log.error(message + ", " + url + ", " + linenumber);
}
// ¡Atención!: La siguiente linea de código va a producir un error
error;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment