Skip to content

Enrich Serilog log events with properties from Open Telemetry spans.

License

Notifications You must be signed in to change notification settings

RehanSaeed/Serilog.Enrichers.Span

Repository files navigation

Banner

Serilog.Enrichers.Span NuGet Package Serilog.Enrichers.Span package in serilog-exceptions feed in Azure Artifacts Serilog.Enrichers.Span NuGet Package Downloads Twitter URL Twitter Follow

Enrich Serilog log events with properties from open telemetry spans using .NET's Activity API.

❗ Important

This repository is now deprecated. Serilog now has the native ability to log span related data. See #332.

What Does It Do?

Enriches logs with a spans unique identifier, parent unique identifier and ASP.NET's trace unique identifier. Serilog.Enrichers.Span is an add-on to Serilog to log exception details and custom properties that are not output in Exception.ToString().

Getting Started

Add the Serilog.Enrichers.Span NuGet package.

dotnet add package Serilog.Enrichers.Span

When setting up your logger, add the WithSpan() line like so:

using Serilog;
using Serilog.Enrichers.Span;

ILogger logger = new LoggerConfiguration()
    .Enrich.WithSpan()
    .WriteTo.RollingFile(
        new JsonFormatter(renderMessage: true), 
        @"C:\logs\log-{Date}.txt")    
    .CreateLogger();

Continuous Integration

Name Operating System Status History
Azure Pipelines Ubuntu Azure Pipelines Ubuntu Build Status
Azure Pipelines Mac Azure Pipelines Mac Build Status
Azure Pipelines Windows Azure Pipelines Windows Build Status
Azure Pipelines Overall Azure Pipelines Overall Build Status Azure DevOps Build History
GitHub Actions Ubuntu, Mac & Windows GitHub Actions Status GitHub Actions Build History
AppVeyor Ubuntu, Mac & Windows AppVeyor Build status AppVeyor Build History

Contributions and Thanks

Please view the contributing guide for more information.