Skip to main content

[JavaScript] Why are all my console logs sent as errors?

Issue

I enabled captureConsoleIntegration, and now my console.log calls (and other console output) show up in Sentry and consume error quota.

Applies To

  • All SaaS Customers and Self-Hosted Users

  • JavaScript SDK

  • Error Monitoring

Resolution

captureConsoleIntegration captures Console API calls and sends them to Sentry with captureMessage or captureException, depending on the console level. By default it captures log, info, warn, error, debug, and assert. Each captured call creates a Sentry event and uses error quota, even when the original console level was not error.

To limit which console methods create events, set the levels option. Only the listed levels are sent. For example, capture only error:

Sentry.init({
  dsn: "https://[email protected]/0",
  integrations: [
    Sentry.captureConsoleIntegration({
      levels: ["error"],
    }),
  ],
});

If you want console output as Sentry Logs instead of error events, use consoleLoggingIntegration from the Logs documentation. That path does not replace captureConsoleIntegration for error-quota events.

Did this answer your question?