A function that takes a 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.
A function that takes a 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.
A function that takes a 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.
A function that takes a 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.
A function that takes a 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.
A function that takes a 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.
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 which is used for log entries logged with GoogleLogger.
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 which is used for log entries logged with GoogleLogger.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eGoogleDiagnosticsWebHostBuilderExtensions\u003c/code\u003e class provides methods to configure Google Diagnostics services, including Logging, Tracing, and Error Reporting, within an \u003ccode\u003eIWebHostBuilder\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThere are two \u003ccode\u003eUseGoogleDiagnostics\u003c/code\u003e methods available, both now obsolete, that allow configuration of Google Diagnostics either via functions that retrieve configuration parameters from the \u003ccode\u003eWebHostBuilderContext\u003c/code\u003e or directly via string values and option instances, with all of them providing a set of optional parameters.\u003c/p\u003e\n"],["\u003cp\u003eThese \u003ccode\u003eUseGoogleDiagnostics\u003c/code\u003e methods enable the configuration of a project ID, service name, and service version, with automatic detection when running on Google App Engine (GAE), Google Compute Engine (GCE), or Google Kubernetes Engine (GKE).\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eUseGoogleDiagnostics\u003c/code\u003e methods also offer the ability to specify options for logging, tracing, and error reporting, with default options being used if these are not provided.\u003c/p\u003e\n"],["\u003cp\u003eThe latest version of this extension is \u003ccode\u003e4.4.0\u003c/code\u003e, while \u003ccode\u003e4.3.1\u003c/code\u003e is also listed, and they recommend using \u003ccode\u003eGoogle.Cloud.Diagnostics.AspNetCore.AspNetCoreGoogleDiagnosticsExtensions\u003c/code\u003e instead.\u003c/p\u003e\n"]]],[],null,["# Class GoogleDiagnosticsWebHostBuilderExtensions (4.4.0)\n\nVersion latestkeyboard_arrow_down\n\n- [4.4.0 (latest)](/dotnet/docs/reference/Google.Cloud.Diagnostics.AspNetCore/latest/Google.Cloud.Diagnostics.AspNetCore.GoogleDiagnosticsWebHostBuilderExtensions)\n- [4.3.1](/dotnet/docs/reference/Google.Cloud.Diagnostics.AspNetCore/4.3.1/Google.Cloud.Diagnostics.AspNetCore.GoogleDiagnosticsWebHostBuilderExtensions) \n\n [Obsolete(\"Use Google.Cloud.Diagnostics.AspNetCore.AspNetCoreGoogleDiagnosticsExtensions instead.\")]\n public static class GoogleDiagnosticsWebHostBuilderExtensions\n\nExtensions to configure Google Diagnostics on the [IWebHostBuilder](https://learn.microsoft.com/dotnet/api/microsoft.aspnetcore.hosting.iwebhostbuilder). \n\nInheritance\n-----------\n\n[Object](https://learn.microsoft.com/dotnet/api/system.object) \\\u003e GoogleDiagnosticsWebHostBuilderExtensions \n\nInherited Members\n-----------------\n\n[Object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode#system-object-gethashcode) \n[Object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype#system-object-gettype) \n[Object.MemberwiseClone()](https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone#system-object-memberwiseclone) \n[Object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring#system-object-tostring)\n\nNamespace\n---------\n\n[Google.Cloud.Diagnostics.AspNetCore](/dotnet/docs/reference/Google.Cloud.Diagnostics.AspNetCore/latest/Google.Cloud.Diagnostics.AspNetCore)\n\nAssembly\n--------\n\nGoogle.Cloud.Diagnostics.AspNetCore.dll\n\nMethods\n-------\n\n### UseGoogleDiagnostics(IWebHostBuilder, Func\\\u003cWebHostBuilderContext, String\\\u003e, Func\\\u003cWebHostBuilderContext, String\\\u003e, Func\\\u003cWebHostBuilderContext, String\\\u003e, Func\\\u003cWebHostBuilderContext, LoggerOptions\\\u003e, Func\\\u003cWebHostBuilderContext, TraceOptions\\\u003e, Func\\\u003cWebHostBuilderContext, ErrorReportingOptions\\\u003e)\n\n [Obsolete(\"Use Google.Cloud.Diagnostics.AspNetCore.AspNetCoreGoogleDiagnosticsExtensions instead.\")]\n public static IWebHostBuilder UseGoogleDiagnostics(this IWebHostBuilder builder, Func\u003cWebHostBuilderContext, string\u003e projectIdGetter, Func\u003cWebHostBuilderContext, string\u003e serviceNameGetter, Func\u003cWebHostBuilderContext, string\u003e serviceVersionGetter, Func\u003cWebHostBuilderContext, LoggerOptions\u003e loggerOptionsGetter = null, Func\u003cWebHostBuilderContext, TraceOptions\u003e traceOptionsGetter = null, Func\u003cWebHostBuilderContext, ErrorReportingOptions\u003e errorReportingOptionsGetter = null)\n\nConfigures Google Diagnostics services for Logging, Tracing and Error Reporting middleware.\n\n### UseGoogleDiagnostics(IWebHostBuilder, String, String, String, LoggerOptions, TraceOptions, ErrorReportingOptions)\n\n [Obsolete(\"Use Google.Cloud.Diagnostics.AspNetCore.AspNetCoreGoogleDiagnosticsExtensions instead.\")]\n 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)\n\nConfigures Google Diagnostics services for Logging, Tracing and Error Reporting middleware."]]