Skip to main content

[Angular] Why did browser console error logging stop after I enabled Sentry?

Issue

After enabling the Sentry Angular SDK (@sentry/angular), errors no longer appear in the browser console. I expected Angular’s ErrorHandler console output (console.error) to keep working alongside Sentry.

Applies To

  • All SaaS Customers and Self-Hosted Users

  • Angular SDK (@sentry/angular)

  • Error Monitoring

Resolution

By default, Sentry’s Angular ErrorHandler still logs errors to the browser console. The logErrors option defaults to true.

Sentry replaces Angular’s default ErrorHandler with Sentry.createErrorHandler() so Sentry can capture errors. That handler calls console.error when logErrors is true.

If browser console error logging stopped after you added Sentry:

  1. Search your app for createErrorHandler, SentryErrorHandler, or logErrors.

  2. If you pass logErrors: false, set logErrors to true (or remove the option so the default applies).

  3. Register the handler in app.config.ts or app.module.ts like this:

    import { ErrorHandler } from "@angular/core";
    import * as Sentry from "@sentry/angular";{
      provide: ErrorHandler,
      useValue: Sentry.createErrorHandler({
        logErrors: true,
      }),
    }

  4. If you use a custom ErrorHandler that extends Sentry.SentryErrorHandler, pass { logErrors: true } to super(...), and call super.handleError(error) so Sentry still captures the error.

  5. If you replaced Angular’s ErrorHandler with a fully custom handler that does not call console.error and does not use Sentry’s handler, add console logging back, or switch to Sentry.createErrorHandler({ logErrors: true }).

For all ErrorHandler options, see the Angular Error Handler documentation.

Did this answer your question?