Documentation Menu

__jsnlog_configure function

If defined, the library executes this function after it has loaded.


This is an infrastructure related feature.

After the jsnlog.js library has loaded, it checks whether there is a global function with the name __jsnlog_configure. If there is, it executes that function.

This enables authors of server side components to generate a JavaScript block at the beginning of the page that configures loggers, appenders, etc., based on a server side configuration file. By encapsulating this JavaScript in a function __jsnlog_configure, they can ensure that the JavaScript will be executed when jsnlog.js has been loaded.

Without the function, they would have to make sure that jsnlog.js was already loaded before their configuration code. This can be hard to do, especially if the jsnlog.min.js file is loaded as an AMD module.

The function takes one argument: the JL object itself. Here is how jsnlog.js calls the function, after having made sure that it actually exists:

if (typeof __jsnlog_configure == 'function') {