The Logging Framework for JS

I like log4net .The library is very easy for using and configuration and has an amazing set of features. I found an interesting project that allow to ASP.NET(AJAX) developers to add logging abilities to JavaScript .The project called log4js .It’s free and can be downloaded at this link.The main aim of framework is to be very similar to the Net logging framework Log4net.So if you used log4net before you may try log4js.

The log4js contains following appenders:

  • WindowAppender: open a new window in the browser and insert log messages in real time.
  • WindowsEventAppender: send log messages in the MS Windows event manager.
  • FileAppender: write log messages in a local file on the client.
  • AjaxAppender: allow to send log messages to the server with asynchronous HTTP request. There you can process the logging events like you want on server side (ASP.NET).
  • MetatagAppender: add log messages as meta data.

The configuration is done by inserting :

<script src="log4js.js" type="text/javascript"></script> 
<script type="text/javascript"> 
<!-- // 
//initialize the logger  with your category 
var logger = Log4js.getLogger("ajaxTest"); 
//set the level of logging 
//set the AJAX Appender to write the log to 
logger.addAppender(new AjaxAppender("./log4j.jsp")); 
// --> </script> 

Log4js is compatible with almost all current browsers (IE,Firefox,Safari,Opera…)

Technorati Tags: ,,