# Google.Cloud.Diagnostics.Common - Class LoggingOptions (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.LoggingOptions)
- [5.2.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/5.2.0/Google.Cloud.Diagnostics.Common.LoggingOptions)
- [5.1.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/5.1.0/Google.Cloud.Diagnostics.Common.LoggingOptions)
- [5.0.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/5.0.0/Google.Cloud.Diagnostics.Common.LoggingOptions)
- [4.4.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/4.4.0/Google.Cloud.Diagnostics.Common.LoggingOptions)
- [4.3.1](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/4.3.1/Google.Cloud.Diagnostics.Common.LoggingOptions)

    public sealed class LoggingOptions

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

Options for a [GoogleLogger](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/latest/Google.Cloud.Diagnostics.Common.GoogleLogger)".
These are options to configure when and what is logged,
as where [LoggingServiceOptions](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/latest/Google.Cloud.Diagnostics.Common.LoggingServiceOptions) configure the logging service,
including the target GCP project, etc.

## Inheritance

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

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

## Properties

### BufferOptions

    public BufferOptions BufferOptions { get; }

The buffer options for the logger.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/latest/Google.Cloud.Diagnostics.Common.BufferOptions` |   |

### Labels

    public Dictionary<string, string> Labels { get; }

Custom labels for log entries.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.collections.generic.dictionary-2https://learn.microsoft.com/dotnet/api/system.stringhttps://learn.microsoft.com/dotnet/api/system.string` |   |

**Remarks** Keys and values added to [Labels](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/latest/Google.Cloud.Diagnostics.Common.LoggingOptions#Google_Cloud_Diagnostics_Common_LoggingOptions_Labels) should not be null.
If they are, an exception will be thrown 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://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/latest/Google.Cloud.Diagnostics.Common.RetryOptions#Google_Cloud_Diagnostics_Common_RetryOptions_ExceptionHandling).

### LogLevel

    public LogLevel LogLevel { get; }

The minimum log level.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/microsoft.extensions.logging.loglevel` |   |

### LogName

    public string LogName { get; }

The name for the logs.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.string` |   |

### MonitoredResource

    public MonitoredResource MonitoredResource { get; }

The monitored resource. See: <https://cloud.google.com/logging/docs/api/v2/resource-list>

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://cloud.google.com/dotnet/docs/reference/Google.Api.CommonProtos/latest/Google.Api.MonitoredResource.html` |   |

### RetryOptions

    public RetryOptions RetryOptions { get; }

The retry options for the logger.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/latest/Google.Cloud.Diagnostics.Common.RetryOptions` |   |

## Methods

### Create(LogLevel, string, Dictionary\<string, string\>, MonitoredResource, BufferOptions, RetryOptions)

    public static LoggingOptions Create(LogLevel logLevel = LogLevel.Information, string logName = null, Dictionary<string, string> labels = null, MonitoredResource monitoredResource = null, BufferOptions bufferOptions = null, RetryOptions retryOptions = null)

Create a new instance of [LoggingOptions](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/latest/Google.Cloud.Diagnostics.Common.LoggingOptions).

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `logLevel` | `https://learn.microsoft.com/dotnet/api/microsoft.extensions.logging.loglevel` Optional, the minimum log level. Defaults to [Information](https://learn.microsoft.com/dotnet/api/microsoft.extensions.logging.loglevel#microsoft-extensions-logging-loglevel-information) |
| `logName` | `https://learn.microsoft.com/dotnet/api/system.string` Optional, the name of the log. Defaults to 'aspnetcore'. |
| `labels` | `https://learn.microsoft.com/dotnet/api/system.collections.generic.dictionary-2https://learn.microsoft.com/dotnet/api/system.stringhttps://learn.microsoft.com/dotnet/api/system.string` Optional, custom labels to be added to log entries. Keys and values added to `labels` should not be null. If they are, an exception will be thrown 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://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/latest/Google.Cloud.Diagnostics.Common.RetryOptions#Google_Cloud_Diagnostics_Common_RetryOptions_ExceptionHandling). |
| `monitoredResource` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.CommonProtos/latest/Google.Api.MonitoredResource.html` Optional, the monitored resource. The monitored resource will be automatically detected if it is not set and will default to the global resource if the detection fails. See: <https://cloud.google.com/logging/docs/api/v2/resource-list> |
| `bufferOptions` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/latest/Google.Cloud.Diagnostics.Common.BufferOptions` Optional, the buffer options. Defaults to a [Timed](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/latest/Google.Cloud.Diagnostics.Common.BufferType#Google_Cloud_Diagnostics_Common_BufferType_Timed) |
| `retryOptions` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/latest/Google.Cloud.Diagnostics.Common.RetryOptions` Optional, the retry options. Defaults to a [None](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/latest/Google.Cloud.Diagnostics.Common.RetryType#Google_Cloud_Diagnostics_Common_RetryType_None) |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/latest/Google.Cloud.Diagnostics.Common.LoggingOptions` |   |