Skip to content

Console recording BASIC

Ybug automatically captures all unhandled global errors and console output. You can turn this feature on or off by setting the console_log option to true / false, or from your dashboard:

javascript
window.ybug_settings = {
    id: 'XXXXXXXXX',
    console_log: false, // Turn console recorder off
};

Limitations

Because Ybug is loaded asynchronously for performance reasons, it can only capture errors and console output once it is fully loaded. If performance is not a concern, you can put Ybug's JavaScript snippet into the <head> section of the page.

For security reasons, capturing unhandled errors is also limited by browsers. If you see "Script error." in your Ybug console log, the error originates from a JavaScript file on a different origin — also known as a CORS error. See Troubleshooting for more details.

Custom error logging

You can use Ybug's custom error logging to capture errors that have been handled by your application:

javascript
try {
    // Some JS code ...
} catch (err) {
    if (Ybug) { // Make sure Ybug is loaded
        Ybug.log('error', err);

        // You can also log a message
        Ybug.log('log', 'An error happened...');
    }
}