1. Home
  2. Docs
  3. Bugfender SDK for web applications
  4. Send logs

Send logs

Once the SDK has been initialized, you can use the Bugfender object just like you would use the console object:

Bugfender.log('Hello world!');

Also other log levels are available:

Bugfender.fatal('Fatal error message'); // this is not in the console object
Bugfender.error('Error message');
Bugfender.warn('Warning message');
Bugfender.log('Hello world!');
Bugfender.info('Info message');
Bugfender.trace('Trace message'); // this is different than the console object, does not output a stacktrace

Bugfender also accepts string substitutions like the console object does:

for (var i=0; i<5; i++) {
  Bugfender.log("Hello, %s. You've called me %d times.", "Bob", i+1);
}

For more information, check out the MDN docs on console.

Capturing console logs

Probably you might want to get all you app logs in your log viewer, to do this, when you init Bugfender you can enable the console override. For this there’s the overrideConsoleMethods option you can enable/enable. By default the SDK will capture window.console calls.

Send additional details

Bugfender has a more advanced logging system than console.log() which allows you to add tags, specify the file name, line name or function name.

For example, adding a tag will allow you find and filter logs easily in the Bugfender log viewer.

Bugfender.sendLog({ tag: 'tag1', text: 'this is my log' });

Please note in this case the function is sendLog() and the passed parameter is an ILogEntry. All of the fields in the object are optional, if you do not fill them, they will be automatically populated by Bugfender.