Documentation Menu
Configuring JSNLog using client code
Client side configuration methods
The jsnlog.js library has several configuration methods:
- Configuring global JSNLog wide settings;
- Creating and configuring a Logger;
- Creating and configuring an Ajax Appender;
- Creating and configuring a Console Appender.
Making sure jsnlog.js has loaded when running configuration code
In some scenarios, such as with
AMD modules
The solution is to put your configuration code in a global method called
__jsnlog_configure
Your configuration code would look like this:
__jsnlog_configure = function (JL) { ... configuration code }; try { __jsnlog_configure(JL); } catch(e) {};
This solves the race condition:
- If your configuration code loads after jsnlog.js, it is normally executed.
- If your configuration code loads before jsnlog.js, there will be an exception, which is swallowed by the try ... catch. Then when jsnlog.js loads, it calls __jsnlog_configure and now your configuration code will run successfully.