# Google.Cloud.Diagnostics.Common - Class LoggingExtensions (5.3.0)

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

- [5.3.0 (latest)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/latest/Google.Cloud.Diagnostics.Common.LoggingExtensions)
- [5.2.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/5.2.0/Google.Cloud.Diagnostics.Common.LoggingExtensions)
- [5.1.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/5.1.0/Google.Cloud.Diagnostics.Common.LoggingExtensions)
- [5.0.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/5.0.0/Google.Cloud.Diagnostics.Common.LoggingExtensions)
- [4.4.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/4.4.0/Google.Cloud.Diagnostics.Common.LoggingExtensions)
- [4.3.1](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/4.3.1/Google.Cloud.Diagnostics.Common.LoggingExtensions)

    public static class LoggingExtensions

Reference documentation and code samples for the Google.Cloud.Diagnostics.Common class LoggingExtensions.

Extension methods for registering Google Cloud Logging.

## Inheritance

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

## Inherited Members

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

## Namespace

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

## Assembly

Google.Cloud.Diagnostics.Common.dll

## Methods

### AddGoogle(ILoggingBuilder, LoggingServiceOptions)

    public static ILoggingBuilder AddGoogle(this ILoggingBuilder builder, LoggingServiceOptions options = null)

Adds a [GoogleLoggerProvider](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/latest/Google.Cloud.Diagnostics.Common.GoogleLoggerProvider) for [GoogleLogger](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/latest/Google.Cloud.Diagnostics.Common.GoogleLogger)s.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `builder` | `https://learn.microsoft.com/dotnet/api/microsoft.extensions.logging.iloggingbuilder` |
| `options` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/latest/Google.Cloud.Diagnostics.Common.LoggingServiceOptions` |

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

### AddLogEntryLabelProviderSingleton\<T\>(IServiceCollection)

    public static IServiceCollection AddLogEntryLabelProviderSingleton<T>(this IServiceCollection services) where T : class, ILogEntryLabelProvider

Adds a [ILogEntryLabelProvider](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/latest/Google.Cloud.Diagnostics.Common.ILogEntryLabelProvider) of type `T` to the service collection instance
as a singleton.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `services` | `https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection` The [IServiceCollection](https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection) instance. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection` | The [IServiceCollection](https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection) instance. |

| **Type Parameter** ||
|---|---|
| **Name** | **Description** |
| `T` | The type of the [ILogEntryLabelProvider](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/latest/Google.Cloud.Diagnostics.Common.ILogEntryLabelProvider) implementation. |

### AddLogEntryLabelProviderSingleton\<T\>(IServiceCollection, Func\<IServiceProvider, T\>)

    public static IServiceCollection AddLogEntryLabelProviderSingleton<T>(this IServiceCollection services, Func<IServiceProvider, T> implementationFactory) where T : class, ILogEntryLabelProvider

Adds a [ILogEntryLabelProvider](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/latest/Google.Cloud.Diagnostics.Common.ILogEntryLabelProvider) of type `T` to the service collection instance
as a singleton.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `services` | `https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection` The [IServiceCollection](https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection) instance. |
| `implementationFactory` | `https://learn.microsoft.com/dotnet/api/system.func-2https://learn.microsoft.com/dotnet/api/system.iserviceprovider` The factory that creates the service. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection` | The [IServiceCollection](https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection) instance. |

| **Type Parameter** ||
|---|---|
| **Name** | **Description** |
| `T` | The type of the [ILogEntryLabelProvider](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/latest/Google.Cloud.Diagnostics.Common.ILogEntryLabelProvider) implementation. |

### AddLogEntryLabelProviderSingleton\<T\>(IServiceCollection, T)

    public static IServiceCollection AddLogEntryLabelProviderSingleton<T>(this IServiceCollection services, T instance) where T : class, ILogEntryLabelProvider

Adds a [ILogEntryLabelProvider](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/latest/Google.Cloud.Diagnostics.Common.ILogEntryLabelProvider) of type `T` to the service collection instance
as a singleton.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `services` | `https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection` The [IServiceCollection](https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection) instance. |
| `instance` | `T` The instance of `T`. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection` | The [IServiceCollection](https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection) instance. |

| **Type Parameter** ||
|---|---|
| **Name** | **Description** |
| `T` | The type of the [ILogEntryLabelProvider](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/latest/Google.Cloud.Diagnostics.Common.ILogEntryLabelProvider) implementation. |