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

    public class EnvironmentNameLogEntryLabelProvider : ILogEntryLabelProvider, ILogEntryLabelProvider

A [ILogEntryLabelProvider](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.AspNetCore/latest/Google.Cloud.Diagnostics.AspNetCore.ILogEntryLabelProvider) implementation which adds the [EnvironmentName](https://learn.microsoft.com/dotnet/api/microsoft.aspnetcore.hosting.ihostingenvironment.environmentname#microsoft-aspnetcore-hosting-ihostingenvironment-environmentname) to the log entry labels.

## Inheritance

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

## Implements

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

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

## Constructors

### EnvironmentNameLogEntryLabelProvider(IHostingEnvironment)

    public EnvironmentNameLogEntryLabelProvider(IHostingEnvironment hostingEnvironment)

Initializes a new instance of the [EnvironmentNameLogEntryLabelProvider](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.AspNetCore/latest/Google.Cloud.Diagnostics.AspNetCore.EnvironmentNameLogEntryLabelProvider) class.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `hostingEnvironment` | `https://learn.microsoft.com/dotnet/api/microsoft.aspnetcore.hosting.ihostingenvironment` The [IHostingEnvironment](https://learn.microsoft.com/dotnet/api/microsoft.aspnetcore.hosting.ihostingenvironment) instance to retrieve the environment name from. |

## Methods

### Invoke(Dictionary\<String, String\>)

    public void Invoke(Dictionary<string, string> labels)

Invokes the provider to augment log entry labels.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `labels` | `https://learn.microsoft.com/dotnet/api/system.collections.generic.dictionary-2<https://learn.microsoft.com/dotnet/api/system.string, https://learn.microsoft.com/dotnet/api/system.string>` A dictionary of log entry labels. Keys and values added to `labels` should not be null. If they are, an exception will be throw when attempting to log an entry. The entry won't be logged and the exception will be propagated depending on the value of [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). |