JavaScript logging and error handling for AngularJS

Added by: Sam Deering





Stars: 23

Watchers: 23

Forks: 5



Module Description

Logging and JavaScript error handling for AngularJS


  • Replaces standard AngularJS $log to version that logs to the server, and optionally to the console using a consoleAppender.
  • Replaces AngularJS $exceptionHandler with version that logs JavaScript exceptions to the server.
  • Provides Interceptors to log AJAX errors and timeouts to the server, and to log warning messages when AJAX responses are slow.

How to use

Install the JSNLog JavaScript Logging Package. Copy logToServer.js to your site and load it into your pages, such as with a script tag.

To use the new $log and $exceptionHandler, simply import module logToServer into your main module, like so:

var app = angular.module('mainmodule', ['logToServer']);

To use the interceptors, add them to the interceptors array for your application:

app.config(['$httpProvider', function($httpProvider) {

When you call $http to send an AJAX message, set the timeout and the delay after which a warning log message is sent in milliseconds in the config object, using timeout and warningAfter:

$http({ method: '...', url: '...', data: ..., timeout: 5000, warningAfter: 2000 })
.success(function (data, status, headers, config) {
.error(function (data, status, headers, config) {

More about AngularJS Error Handling

Module stats last updated: 2017-02-19 15:00:04

Disclaimer: Some data on this page may have been gathered from the authors GitHub respository. If you see any mistakes or outdated information please let us know. Thanks!