# Class ErrorReportingExceptionLoggerExtension (4.4.0)

<button class="button button-with-icon cloud-select-dropdown__button " aria-haspopup="true">Version latest</button>

- [4.4.0 (latest)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.AspNetCore/latest/Google.Cloud.Diagnostics.AspNetCore.ErrorReportingExceptionLoggerExtension)
- [4.3.1](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.AspNetCore/4.3.1/Google.Cloud.Diagnostics.AspNetCore.ErrorReportingExceptionLoggerExtension)

    [Obsolete("Use Google.Cloud.Diagnostics.AspNetCore.AspNetCoreErrorReportingExtensions instead.")]
    public static class ErrorReportingExceptionLoggerExtension

Uses the Google Cloud Error Reporting Exception Logger Middleware.
To ensure all unhandled exceptions are reported, this should be
the first piece of middleware used.

## Inheritance

[Object](https://learn.microsoft.com/dotnet/api/system.object) \> ErrorReportingExceptionLoggerExtension

## Inherited Members

[Object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode#system-object-gethashcode) [Object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype#system-object-gettype) [Object.MemberwiseClone()](https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone#system-object-memberwiseclone) [Object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring#system-object-tostring)

## Namespace

[Google.Cloud.Diagnostics.AspNetCore](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.AspNetCore/latest/Google.Cloud.Diagnostics.AspNetCore)

## Assembly

Google.Cloud.Diagnostics.AspNetCore.dll

## Methods

### AddGoogleExceptionLogging(IServiceCollection, Action\<ErrorReportingServiceOptions\>)

    [Obsolete("Use Google.Cloud.Diagnostics.AspNetCore.AspNetCoreErrorReportingExtensions.AddGoogleErrorReportingForAspNetCore instead.")]
    public static IServiceCollection AddGoogleExceptionLogging(this IServiceCollection services, Action<ErrorReportingServiceOptions> setupAction)

Adds services for middleware that will report all uncaught exceptions to the
Google Cloud Error Reporting API.


Can be used when running on Google App Engine or Google Compute Engine.
The Google Cloud Platform project to report errors to will detected from the
current platform.

<br />

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `services` | `https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection` The service collection. Must not be null. |
| `setupAction` | `https://learn.microsoft.com/dotnet/api/system.action-1<https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.AspNetCore/latest/Google.Cloud.Diagnostics.AspNetCore.ErrorReportingServiceOptions>` Action to set up options. Must not be null. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection` |   |

**Remarks** If [ExceptionHandling](https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/latest/Google.Cloud.Diagnostics.Common.RetryOptions.html#Google_Cloud_Diagnostics_Common_RetryOptions_ExceptionHandling) is set to [Propagate](https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/latest/Google.Cloud.Diagnostics.Common.ExceptionHandling.html#Google_Cloud_Diagnostics_Common_ExceptionHandling_Propagate)
and the [RequestDelegate](https://learn.microsoft.com/dotnet/api/microsoft.aspnetcore.http.requestdelegate) executed by this middleware throws an exception and this
diagnostics library also throws an exception trying to report it an [AggregateException](https://learn.microsoft.com/dotnet/api/system.aggregateexception)
with both exceptions will be thrown. Otherwise only the exception from the [RequestDelegate](https://learn.microsoft.com/dotnet/api/microsoft.aspnetcore.http.requestdelegate)
will be thrown.

### UseGoogleExceptionLogging(IApplicationBuilder)

    [Obsolete("Use Google.Cloud.Diagnostics.AspNetCore.AspNetCoreErrorReportingExtensions.AddGoogleErrorReportingForAspNetCore for configuring Google Cloud Error Reporting in ASP.NET Core applications. There's no need to explicitly register the middleware.")]
    public static IApplicationBuilder UseGoogleExceptionLogging(this IApplicationBuilder app)

Uses middleware that will report all uncaught exceptions to the Google Cloud
Error Reporting API.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `app` | `https://learn.microsoft.com/dotnet/api/microsoft.aspnetcore.builder.iapplicationbuilder` The application builder. Must not be null. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/microsoft.aspnetcore.builder.iapplicationbuilder` |   |