Console logging
Capture console API calls as Sentry logs in React Native.
Sentry Logs
Enable the Sentry Logs feature with enableLogs: true in your Sentry.init call to unlock Sentry's full logging power. With Sentry Logs, you can search, filter, and analyze logs from across your entire application in one place.
Console Logging integration is enabled by default which means calls to the console API will be captured as logs in Sentry. By default the integration instruments console.debug, console.info, console.warn, console.error, console.log, console.trace, and console.assert.
Since version 8.14.0, you can disable the integration with the enableAutoConsoleLogs option. Sentry.logger.* calls still work as expected:
Sentry.init({
...,
enableLogs: true,
enableAutoConsoleLogs: false,
...
})
Sentry.init({
...,
enableLogs: true,
enableAutoConsoleLogs: false,
...
})
On earlier versions, filter the integration out of the integrations array:
Sentry.init({
...,
integrations(integrations) {
return integrations.filter(i => i.name !== 'ConsoleLogs');
},
...
})
Sentry.init({
...,
integrations(integrations) {
return integrations.filter(i => i.name !== 'ConsoleLogs');
},
...
})
You can also filter out the automatically captured logs in beforeSendLog:
Sentry.init({
...,
beforeSendLog: (log) => {
if (log.attributes?.['sentry.origin'] === 'auto.log.console') {
return null;
}
return log;
},
...
})
Sentry.init({
...,
beforeSendLog: (log) => {
if (log.attributes?.['sentry.origin'] === 'auto.log.console') {
return null;
}
return log;
},
...
})
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").