This project is read-only.
Detailed instructions to follow:
1. Install JSNLog.Log4Net with NuGet Package Manager


2. Add configuration information for log4net. It is possible to add this information in a separate config file. For adding this information in a separate file, we need to add this in the web.config file.
<add key="log4net.Config" value="log4net.config" />
<add key="log4net.Config.Watch" value="True" />
<add key="log4net.Internal.Debug" value="true" />
Here, ‘log4net.config’ is the name of the config file. Then we need to define the configuration information for log4net in the file.


In this config file, we define different appender for logging the messages. Here, there are two appender, one is ‘RollingFileAppender’ which log data in the file and another is ‘ADONetAppender’ which saves data in the database.

3. For logging from the c# backend, we need to take a log object and call different


methods through it for logging.

4. For logging from the java script, we need to call the Configure function before any java script is added in the page.
<%# JSNLog.JavascriptLogging.Configure() %>


Then we need to call different functions for logging.
JL("Page Logger").info("Info logging from client side");
JL("Page Logger").debug("Debug logging from client side");
JL("Page Logger").error("Error logging from client side");
JL("Page Logger").fatal("Fatal logging from client side");

If we want to catch every java script errors, we need to define a global function.
window.onerror = function (errorMsg, url, lineNumber, column, errorObj) {
// Send object with all data to server side log, using severity fatal,
// from logger "onerrorLogger"
"msg": "Exception!",
"errorMsg": errorMsg,
"url": url,
"line number": lineNumber,
"column": column
}, errorObj);
// Tell browser to run its own error handler as well
return false;

This function will catch every java script error and log them.

Last edited Nov 10, 2014 at 12:25 PM by mukit, version 7


No comments yet.