<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/opentelemetry-logging-net-ilogger-integration-and-structured-log-export-5b3h28qfa" -->

---
title: OpenTelemetry Logging .NET: ILogger Integration and...
description: A practical guide to integrating OpenTelemetry logging in .NET applications using the ILogger abstraction. Covers setup via AddOpenTelemetry(), automatic trace...
canonical: https://daily.dev/posts/opentelemetry-logging-net-ilogger-integration-and-structured-log-export-5b3h28qfa
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: OpenTelemetry Logging .NET: ILogger Integration and Structured Log Export | daily.dev
og:description: A practical guide to integrating OpenTelemetry logging in .NET applications using the ILogger abstraction. Covers setup via AddOpenTelemetry(), automatic trace...
og:url: https://daily.dev/posts/opentelemetry-logging-net-ilogger-integration-and-structured-log-export-5b3h28qfa
og:image: https://api.daily.dev/og/posts/5B3H28Qfa.png
og:image:alt: OpenTelemetry Logging .NET: ILogger Integration and Structured Log Export
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# OpenTelemetry Logging .NET: ILogger Integration and Structured Log Export

**[We Are .NET](https://daily.dev/sources/wearedotnet)** · 17 min read · 1 upvotes · 0 comments

## Summary

A practical guide to integrating OpenTelemetry logging in .NET applications using the ILogger abstraction. Covers setup via AddOpenTelemetry(), automatic trace context correlation (TraceId/SpanId injected from Activity.Current), configuration options like ParseStateValues, IncludeFormattedMessage, and IncludeScopes, log severity level mapping between .NET and OpenTelemetry, OTLP export for production, batch vs simple processors, and a comparison with Serilog. Includes C# code examples for ASP.NET Core and a FAQ section.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.devleader.ca/2026/07/28/opentelemetry-logging-net-ilogger-integration-and-structured-log-export>

## Questions this post answers

### How do I get trace and span IDs automatically included in my .NET logs?

The OpenTelemetry SDK checks Activity.Current when a LogRecord is created; if there is an active Activity (span), it extracts the TraceId and SpanId and adds them as fields on the LogRecord automatically. No changes to logging calls are needed as long as the code runs inside an active span created via an ActivitySource.

_Developers wiring up trace-to-log correlation can compare configuration approaches like this one on daily.dev._

### What is the difference between ParseStateValues and IncludeFormattedMessage in OpenTelemetry .NET logging?

ParseStateValues, disabled by default, extracts individual key-value pairs like OrderId or UserId from a log message template as separate queryable attributes on the LogRecord. IncludeFormattedMessage instead adds the complete formatted string as an extra attribute, useful for human-readable display rather than field-level querying in log backends.

_Anyone tuning OpenTelemetry logging config in .NET can weigh these tradeoffs alongside similar guides on daily.dev._

### Should I use OpenTelemetry logging or Serilog in a .NET application?

Serilog has a mature sink ecosystem for destinations like Elasticsearch and Splunk plus an established enricher model, while OpenTelemetry logging unifies logs with traces and metrics through a single OTLP pipeline with automatic trace correlation and shared resource configuration. Both can run simultaneously, and greenfield OpenTelemetry-first stacks favor OpenTelemetry logging while mature Serilog investments can keep Serilog and add OpenTelemetry for traces and metrics.

_Teams deciding between logging pipelines can weigh comparisons like this one on daily.dev before committing._

## Similar posts on daily.dev

- [OpenTelemetry ASP.NET Core: Setup, Auto-Instrumentation, and Configuration](https://daily.dev/posts/opentelemetry-asp-net-core-setup-auto-instrumentation-and-configuration-tiydmwrgx) · We Are .NET · 1 upvotes · 0 comments
- [Logging, Metrics, and Distributed Tracing in .NET with OpenTelemetry and ClickStack](https://daily.dev/posts/logging-metrics-and-distributed-tracing-in-net-with-opentelemetry-and-clickstack-ohkhm2db1) · ClickHouse · 4 upvotes · 0 comments
- [Structured Logging Patterns That Actually Survive Production — Daily DevOps & .NET](https://daily.dev/posts/structured-logging-patterns-that-actually-survive-production-daily-devops-net-lphiux5cy) · Daily DevOps & .NET · 6 upvotes · 0 comments
- [Beyond Console.WriteLine: Mastering Structured Logging in .NET](https://daily.dev/posts/beyond-console-writeline-mastering-structured-logging-in-net-hgcoz2ses) · ITNEXT · 10 upvotes · 0 comments

---

Tags: [#.net](https://daily.dev/tags/.net), [#observability](https://daily.dev/tags/observability), [#opentelemetry](https://daily.dev/tags/opentelemetry)

[View this post on daily.dev](https://daily.dev/posts/opentelemetry-logging-net-ilogger-integration-and-structured-log-export-5b3h28qfa)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"OpenTelemetry Logging .NET: ILogger Integration and Structured Log Export","url":"https://daily.dev/posts/opentelemetry-logging-net-ilogger-integration-and-structured-log-export-5b3h28qfa","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/opentelemetry-logging-net-ilogger-integration-and-structured-log-export-5b3h28qfa"},"datePublished":"2026-07-28T22:25:51.925Z","dateModified":"2026-09-14T06:28:04.313Z","description":"A practical guide to integrating OpenTelemetry logging in .NET applications using the ILogger abstraction. Covers setup via AddOpenTelemetry(), automatic trace...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/e4c8bb4daf167afca6746517c5d262a5?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/e4c8bb4daf167afca6746517c5d262a5?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"We Are .NET","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"We Are .NET","logo":"https://media.daily.dev/image/upload/s--BsnVOa3i--/f_auto/v1718347410/logos/wearedotnet","url":"https://daily.dev/sources/wearedotnet"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/opentelemetry-logging-net-ilogger-integration-and-structured-log-export-5b3h28qfa","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":1},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":".net,observability,opentelemetry","timeRequired":"PT17M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"We Are .NET","item":"https://daily.dev/sources/wearedotnet"},{"@type":"ListItem","position":3,"name":"OpenTelemetry Logging .NET: ILogger Integration and Structured Log Export"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/opentelemetry-logging-net-ilogger-integration-and-structured-log-export-5b3h28qfa#faq","mainEntity":[{"@type":"Question","name":"How do I get trace and span IDs automatically included in my .NET logs?","acceptedAnswer":{"@type":"Answer","text":"The OpenTelemetry SDK checks Activity.Current when a LogRecord is created; if there is an active Activity (span), it extracts the TraceId and SpanId and adds them as fields on the LogRecord automatically. No changes to logging calls are needed as long as the code runs inside an active span created via an ActivitySource. Developers wiring up trace-to-log correlation can compare configuration approaches like this one on daily.dev."}},{"@type":"Question","name":"What is the difference between ParseStateValues and IncludeFormattedMessage in OpenTelemetry .NET logging?","acceptedAnswer":{"@type":"Answer","text":"ParseStateValues, disabled by default, extracts individual key-value pairs like OrderId or UserId from a log message template as separate queryable attributes on the LogRecord. IncludeFormattedMessage instead adds the complete formatted string as an extra attribute, useful for human-readable display rather than field-level querying in log backends. Anyone tuning OpenTelemetry logging config in .NET can weigh these tradeoffs alongside similar guides on daily.dev."}},{"@type":"Question","name":"Should I use OpenTelemetry logging or Serilog in a .NET application?","acceptedAnswer":{"@type":"Answer","text":"Serilog has a mature sink ecosystem for destinations like Elasticsearch and Splunk plus an established enricher model, while OpenTelemetry logging unifies logs with traces and metrics through a single OTLP pipeline with automatic trace correlation and shared resource configuration. Both can run simultaneously, and greenfield OpenTelemetry-first stacks favor OpenTelemetry logging while mature Serilog investments can keep Serilog and add OpenTelemetry for traces and metrics. Teams deciding between logging pipelines can weigh comparisons like this one on daily.dev before committing."}}]}
```

