Skip to content

server.address is missing from Structured Logs #4493

Done

Description

@tsondergaard

Package

Sentry.AspNetCore

.NET Flavor

.NET Core

.NET Version

8.0.413

OS

Windows

OS Version

Windows 11 Enterprise 24H2

Development Environment

Visual Studio Code (Windows)

SDK Version

5.14.1

Self-Hosted Sentry Version

No response

Workload Versions

dotnet workload list

Installed Workload Id      Manifest Version      Installation Source
--------------------------------------------------------------------

Use `dotnet workload search` to find additional workloads to install.

UseSentry or SentrySdk.Init call

I just call builder.WebHost.UseSentry() in Program.cs.

Steps to Reproduce

  1. Create an ASP.NET Core hello world app
  2. Run dotnet add package Sentry.AspNetCore
  3. Edit appsettings.json as below
  4. Include this in Program.cs: builder.WebHost.UseSentry();
{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft.AspNetCore": "Warning"
    },
    "File": {
      "Path": null
    }
  },
  "Sentry": {
    "Dsn": "https://[email protected]/xxx",
    "SendDefaultPii": true,
    "MaxRequestBodySize": "Always",
    "MinimumBreadcrumbLevel": "Debug",
    "MinimumEventLevel": "Debug",
    "AttachStackTrace": true,
    "Debug": true,
    "DiagnosticLevel": "Error",
    "TracesSampleRate": 1.0,
    "Experimental": {
      "EnableLogs": true
    }
  }
}

Expected Result

https://docs.sentry.io/platforms/dotnet/guides/extensions-logging/logs/#server-attributes says there shall be a server.address attribute in Logs. There doesn't seem to be. I expected something like this where the server.address is present.

{
  "payload_size": "577",
  "project_id": "xxx",
  "tags[microsoft.extensions.logging.event.id,number]": "2",
  "timestamp_precise": "1756899350742000000",
  "environment": "development",
  "message": "Connection id \"0HNFARN182IEO\" stopped.",
  "message.parameter.ConnectionId": "0HNFARN182IEO",
  "message.template": "Connection id \"{ConnectionId}\" stopped.",
  "microsoft.extensions.logging.category_name": "Microsoft.AspNetCore.Server.Kestrel.Connections",
  "microsoft.extensions.logging.event.name": "ConnectionStop",
  "release": "[email protected]+xxx",
  "sdk.name": "sentry.dotnet.aspnetcore",
  "sdk.version": "5.14.1",
  "server.address": "Foo",
  "severity": "debug",
  "trace": "ad624f73866444b9a0f18424e4e0e64f",
  "trace.parent_span_id": "60d35e983820623a",
  "id": "dbfc4db54fe883ac1871d6985c0f9901",
  "observed_timestamp_nanos": "1756899355847905746"
}

Actual Result

I get this, notice server.address is not present:

{
  "payload_size": "577",
  "project_id": "xxx",
  "tags[microsoft.extensions.logging.event.id,number]": "2",
  "timestamp_precise": "1756899350742000000",
  "environment": "development",
  "message": "Connection id \"0HNFARN182IEO\" stopped.",
  "message.parameter.ConnectionId": "0HNFARN182IEO",
  "message.template": "Connection id \"{ConnectionId}\" stopped.",
  "microsoft.extensions.logging.category_name": "Microsoft.AspNetCore.Server.Kestrel.Connections",
  "microsoft.extensions.logging.event.name": "ConnectionStop",
  "release": "[email protected]+xxx",
  "sdk.name": "sentry.dotnet.aspnetcore",
  "sdk.version": "5.14.1",
  "severity": "debug",
  "trace": "ad624f73866444b9a0f18424e4e0e64f",
  "trace.parent_span_id": "60d35e983820623a",
  "id": "dbfc4db54fe883ac1871d6985c0f9901",
  "observed_timestamp_nanos": "1756899355847905746"
}

I can put a server.address attribute there by changing my call to UseSentry like this:

builder.WebHost.UseSentry(o =>
    {
        o.Experimental.SetBeforeSendLog(static log =>
        {
            log.SetAttribute("server.address", Environment.MachineName);
            return log;
        });
    });

Having to do this is not consistent with the documentation at https://docs.sentry.io/platforms/dotnet/guides/extensions-logging/logs/#server-attributes

Activity

  1. added
    Bug
    .NET
    on Sep 3, 2025
  2. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Sep 3, 2025
  3. linear commented on Sep 3, 2025

    @linear
  4. self-assigned this
    on Sep 3, 2025
  5. changed the title [-]server.address is missing[/-] [+]server.address is missing from Structured Logs[/+] on Sep 3, 2025
  6. jamescrosswell commented on Sep 3, 2025

    @jamescrosswell
    Collaborator

    Thanks for the early feedback @tsondergaard !

    @Flash0ver it looks like this already gets added automatically for events (just not yet for structured logs):

    [Fact]
    public void Process_ServerName_SetToEnvironmentMachineName()
    {
    var target = new SentryEvent();
    _ = _sut.Process(target);
    Assert.Equal(Environment.MachineName, target.ServerName);
    }

  7. jamescrosswell commented on Nov 26, 2026

    @jamescrosswell
    Collaborator

    Fixed in #5216 (6.7.0). Structured logs now carry server.address, taken from ServerName if you set one, or from the machine name when SendDefaultPii is on. Sending the machine name without SendDefaultPii is tracked in #5957.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    .NETBugLogs

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions