Log only production environment of Angular 2 app

How to configure logging only for a specific environment (i.e. production) in an Angular 2 app?

Let’s say I define environment in a config file by setting a constant production: true and then use it through application.

I solved it by checking environment constant while defining RavenErrorHandler class:

class RavenErrorHandler implements ErrorHandler {
  handleError(err:any) : void {
    if (environment.production) {

it works but does not look nice.
any better idea?

You can simply not set the DSN value and it will disable reporting.

I think it looks nice?

Then if you are not in production, you can log information to the console instead?

That is how we use sentry in our Angular application. If production, then report to Sentry, otherwise report to console.