.Net + JSPHP + JSJS Only

Client side logging integrated with ASP.NET and MVC

JSNLog lets you insert loggers in your client side JavaScript, configure them in your web.config, and store their messages in your server side logs - without any server side coding.

Works with your server side loggers

  • Sends log messages from the client to the server using AJAX.
  • Hands the log messages to your server side logging package.
  • Supports Log4Net, NLog, Elmah, Common.Logging.
  • Integrate JSNLog with Java.

Insert loggers in your JavaScript

JL("jsLogger").info("log message");

Log JavaScript exceptions, with their stack traces

try { 
    ... 
} catch(e) { 
    JL().fatalException("Exception info", e); 
}

Configure loggers in your web.config

<logger name="jslogger" level="FATAL" />

Or configure them in your JavaScript code

JL("jsLogger").setOptions({ "level": 4000 });

Only log for certain user agents or IP addresses

<logger userAgentRegex="MSIE 7|MSIE 8" />

Suppress messages that match a regular expression

<logger disallow="suppress me" />

Log objects as well as strings

var obj = {"f1": "v1", "f2": "v2"};
JL().log(2500, obj);

Pass in function that returns log info

JL().log(2500, function() {
    // Only executed when log info
    // will actually be logged.
    var loginfo = expensiveOperation();
    return loginfo;
});

Get the info you need, but only when you need it

  • To solve JavaScript exceptions, you often need to know what happened before they happened.
  • But you don't want to send trace messages with that context unless there actually is an exception.
  • Solution: JSNLog lets you buffer log messages on the client, and only send them when there is a fatal message.

Limit total messages sent to server

<jsnlog maxMessages="3">

Reduce AJAX requests by batching log messages

<ajaxAppender name="appender1" batchSize="3"/>

Automatically store client side log data in server side logs

LoggerMessage
csLoggerServer side error message
jsLoggerClient side fatal message
csLogger2Server side info message
...

Suppress duplicate messages

LoggerMessage
jsLoggerx too high (x = 5)
jsLoggerx too high (x = 6)
jsLoggerx too high (x = 7)
jsLoggerx too high (x = 8)
jsLoggerx too high (x = 9)

See which messages belong to the same request

Request IDMessage
D623A22B-3454....An error message
CB0734CE-4C99....A fatal message
D623A22B-3454....Some other message
...

Show log data in the console

Switch console logging on or off in your web.config.