mperdeck/jsnlog.js

Stop logging to URL via configuration

Akkora opened this issue · 1 comments

We have an issue, where we are logging to an URL and we need to stop logging because the endpoint is protected and our authorization information expired.

I guess this is the correct option, but it only works if it is called before the ajaxAppender is added.
JL.setOptions({ enabled: false });

Is there any other option to disable logging? We also tried removing the appenders, but we did not have success with this.

I did a bit of hunting through the code (jsnlog.ts), and found that your original approach using
JL.setOptions({ enabled: false })
should work.

However, it may not work immediately. The enabled flag is checked by the logger class when it determines whether an entry should be logged, and by the appender when an item is given to it by a logger (via the appender log method). But once an appender has accepted an item, it often stores it in a buffer, for example to batch log items, or while waiting for a response from the server for a previous log item. The items in those buffers will still be sent, even when you set enabled to false.