# Class GoogleDiagnosticsWebHostBuilderExtensions (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.GoogleDiagnosticsWebHostBuilderExtensions)
- [4.3.1](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.AspNetCore/4.3.1/Google.Cloud.Diagnostics.AspNetCore.GoogleDiagnosticsWebHostBuilderExtensions)

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

Extensions to configure Google Diagnostics on the [IWebHostBuilder](https://learn.microsoft.com/dotnet/api/microsoft.aspnetcore.hosting.iwebhostbuilder).

## Inheritance

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

## 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

### UseGoogleDiagnostics(IWebHostBuilder, Func\<WebHostBuilderContext, String\>, Func\<WebHostBuilderContext, String\>, Func\<WebHostBuilderContext, String\>, Func\<WebHostBuilderContext, LoggerOptions\>, Func\<WebHostBuilderContext, TraceOptions\>, Func\<WebHostBuilderContext, ErrorReportingOptions\>)

    [Obsolete("Use Google.Cloud.Diagnostics.AspNetCore.AspNetCoreGoogleDiagnosticsExtensions instead.")]
    public static IWebHostBuilder UseGoogleDiagnostics(this IWebHostBuilder builder, Func<WebHostBuilderContext, string> projectIdGetter, Func<WebHostBuilderContext, string> serviceNameGetter, Func<WebHostBuilderContext, string> serviceVersionGetter, Func<WebHostBuilderContext, LoggerOptions> loggerOptionsGetter = null, Func<WebHostBuilderContext, TraceOptions> traceOptionsGetter = null, Func<WebHostBuilderContext, ErrorReportingOptions> errorReportingOptionsGetter = null)

Configures Google Diagnostics services for Logging, Tracing and Error Reporting middleware.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `builder` | `https://learn.microsoft.com/dotnet/api/microsoft.aspnetcore.hosting.iwebhostbuilder` The [IWebHostBuilder](https://learn.microsoft.com/dotnet/api/microsoft.aspnetcore.hosting.iwebhostbuilder) instance. |
| `projectIdGetter` | `https://learn.microsoft.com/dotnet/api/system.func-2<https://learn.microsoft.com/dotnet/api/microsoft.aspnetcore.hosting.webhostbuildercontext, https://learn.microsoft.com/dotnet/api/system.string>` A function that takes a [WebHostBuilderContext](https://learn.microsoft.com/dotnet/api/microsoft.aspnetcore.hosting.webhostbuildercontext) and retrieves the Google Cloud Platform project ID. Cannot be null but can return a null value for the project ID, in such a case and if running on GAE/GCE/GKE the project ID will be detected from the platform. |
| `serviceNameGetter` | `https://learn.microsoft.com/dotnet/api/system.func-2<https://learn.microsoft.com/dotnet/api/microsoft.aspnetcore.hosting.webhostbuildercontext, https://learn.microsoft.com/dotnet/api/system.string>` A function that takes a [WebHostBuilderContext](https://learn.microsoft.com/dotnet/api/microsoft.aspnetcore.hosting.webhostbuildercontext) and retrieves the identifier of the service used for exception logging, such as the name of the executable or job. Cannot be null but can return a null value for the service name, in such a case and if running on GAE the service name will be detected from the platform. |
| `serviceVersionGetter` | `https://learn.microsoft.com/dotnet/api/system.func-2<https://learn.microsoft.com/dotnet/api/microsoft.aspnetcore.hosting.webhostbuildercontext, https://learn.microsoft.com/dotnet/api/system.string>` A function that takes a [WebHostBuilderContext](https://learn.microsoft.com/dotnet/api/microsoft.aspnetcore.hosting.webhostbuildercontext) and retrieves the version of the service or the source code used for exception logging. Cannot be null but can return a null value for the service version, in such a case and if running on GAE the service version will be detected from the platform. |
| `loggerOptionsGetter` | `https://learn.microsoft.com/dotnet/api/system.func-2<https://learn.microsoft.com/dotnet/api/microsoft.aspnetcore.hosting.webhostbuildercontext, https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.AspNetCore/latest/Google.Cloud.Diagnostics.AspNetCore.LoggerOptions>` A function that takes a [WebHostBuilderContext](https://learn.microsoft.com/dotnet/api/microsoft.aspnetcore.hosting.webhostbuildercontext) and retrieves the options to use for logging. May be null or return a null value for the options; in either of these cases the default options will be used. |
| `traceOptionsGetter` | `https://learn.microsoft.com/dotnet/api/system.func-2<https://learn.microsoft.com/dotnet/api/microsoft.aspnetcore.hosting.webhostbuildercontext, https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/latest/Google.Cloud.Diagnostics.Common.TraceOptions.html>` A function that takes a [WebHostBuilderContext](https://learn.microsoft.com/dotnet/api/microsoft.aspnetcore.hosting.webhostbuildercontext) and retrieves the options to use for tracing. May be null or return a null value for the options; in either of these cases the default options will be used. |
| `errorReportingOptionsGetter` | `https://learn.microsoft.com/dotnet/api/system.func-2<https://learn.microsoft.com/dotnet/api/microsoft.aspnetcore.hosting.webhostbuildercontext, https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/latest/Google.Cloud.Diagnostics.Common.ErrorReportingOptions.html>` A function that takes a [WebHostBuilderContext](https://learn.microsoft.com/dotnet/api/microsoft.aspnetcore.hosting.webhostbuildercontext) and retrieves the options to use for errorReporting. May be null or return a null value for the options; in either of these cases the default options will be used. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/microsoft.aspnetcore.hosting.iwebhostbuilder` | The [IWebHostBuilder](https://learn.microsoft.com/dotnet/api/microsoft.aspnetcore.hosting.iwebhostbuilder) instance. |

### UseGoogleDiagnostics(IWebHostBuilder, String, String, String, LoggerOptions, TraceOptions, ErrorReportingOptions)

    [Obsolete("Use Google.Cloud.Diagnostics.AspNetCore.AspNetCoreGoogleDiagnosticsExtensions instead.")]
    public static IWebHostBuilder UseGoogleDiagnostics(this IWebHostBuilder builder, string projectId = null, string serviceName = null, string serviceVersion = null, LoggerOptions loggerOptions = null, TraceOptions traceOptions = null, ErrorReportingOptions errorReportingOptions = null)

Configures Google Diagnostics services for Logging, Tracing and Error Reporting middleware.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `builder` | `https://learn.microsoft.com/dotnet/api/microsoft.aspnetcore.hosting.iwebhostbuilder` The [IWebHostBuilder](https://learn.microsoft.com/dotnet/api/microsoft.aspnetcore.hosting.iwebhostbuilder) instance. |
| `projectId` | `https://learn.microsoft.com/dotnet/api/system.string` The Google Cloud Platform project ID. If unspecified and running on GAE/GCE/GKE the project ID will be detected from the platform. |
| `serviceName` | `https://learn.microsoft.com/dotnet/api/system.string` An identifier of the service used for exception logging (through Error Reporting), such as the name of the executable or job. If unspecified and running on GAE the service name will be detected from the platform. This may be different from [ServiceName](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.AspNetCore/latest/Google.Cloud.Diagnostics.AspNetCore.LoggerOptions#Google_Cloud_Diagnostics_AspNetCore_LoggerOptions_ServiceName) which is used for log entries logged with [GoogleLogger](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.AspNetCore/latest/Google.Cloud.Diagnostics.AspNetCore.GoogleLogger). |
| `serviceVersion` | `https://learn.microsoft.com/dotnet/api/system.string` A string that represents the version of the service or the source code used for exception logging. If unspecified and running on GAE the service version will be detected from the platform. This may be different from [Version](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.AspNetCore/latest/Google.Cloud.Diagnostics.AspNetCore.LoggerOptions#Google_Cloud_Diagnostics_AspNetCore_LoggerOptions_Version) which is used for log entries logged with [GoogleLogger](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.AspNetCore/latest/Google.Cloud.Diagnostics.AspNetCore.GoogleLogger). |
| `loggerOptions` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.AspNetCore/latest/Google.Cloud.Diagnostics.AspNetCore.LoggerOptions` The options for logging. May be null, in which case default options will be used. |
| `traceOptions` | `https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/latest/Google.Cloud.Diagnostics.Common.TraceOptions.html` The options for tracing. May be null, in which case default options will be used. |
| `errorReportingOptions` | `https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/latest/Google.Cloud.Diagnostics.Common.ErrorReportingOptions.html` The options for error reporting. May be null, in which case default options will be used. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/microsoft.aspnetcore.hosting.iwebhostbuilder` | The [IWebHostBuilder](https://learn.microsoft.com/dotnet/api/microsoft.aspnetcore.hosting.iwebhostbuilder) instance. |