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

    [Obsolete("Use Google.Cloud.Diagnostics.Common.ITraceContext instead.")]
    public sealed class TraceContextForLogEntry

Represents a trace context (Trace ID and Span ID)
for a log entry.
These values can be attached to a log entry to establish the
relation of it and a trace.

## Inheritance

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

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

### TraceContextForLogEntry(String, String)

    public TraceContextForLogEntry(string traceId, string spanId)

Creates a new trace context.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `traceId` | `https://learn.microsoft.com/dotnet/api/system.string` The trace ID. Must not be null. |
| `spanId` | `https://learn.microsoft.com/dotnet/api/system.string` The span ID, should be null if there's no span. |

## Properties

### SpanId

    public string SpanId { get; }

The span ID to associate the log entry with,
or null if there's currently no open span.

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

**Remarks** For this to be matched to a span being stored in Google Cloud Trace,
its format should be the same that the Trace API v2 uses: a 16-character hexadecimal
encoding of an 8-byte array, such as `000000000000004a`. A check is not performed
to ensure this format is used, so as to allow for this value to refer to spans other
than those stored in Google Cloud Trace.

### TraceId

    public string TraceId { get; }

The trace ID to associate the log entry with.
Must not be null.

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