---
title: "Serilog's UseSerilog() starves Azure Monitor OpenTelemetry of logs, so alerts on App Insights traces never fire"
url: "https://www.dariuszparys.com/notes/serilog-useserilog-starves-azure-monitor-opentelemetry"
author: "Dariusz Parys"
published: 2026-11-27T00:00:00.000Z
description: "Log alerts on Application Insights traces never fired because UseSerilog() replaced the OpenTelemetry logger provider, so the Azure Monitor exporter received no log records."
tags:
  - ".NET"
  - "Observability"
---

# Serilog's UseSerilog() starves Azure Monitor OpenTelemetry of logs, so alerts on App Insights traces never fire

## Context

An ASP.NET Core backend on Azure Container Apps logged through Serilog and
exported telemetry with the Azure Monitor OpenTelemetry distro. Log-based alert
rules queried Application Insights `traces`. They deployed without error and
never fired, although the lines they looked for were being logged.

## The insight

The app logged happily to the console while `traces` stayed empty for months.

```csharp
Log.Logger = new LoggerConfiguration()
    .WriteTo.Console()
    .WriteTo.OpenTelemetry()   // OTLP to localhost:4317 by default, not Azure Monitor
    .CreateLogger();

builder.Host.UseSerilog();     // replaces the ILogger providers

builder.Services.AddOpenTelemetry().UseAzureMonitor();  // its log exporter receives nothing
```

- `UseSerilog()` replaces the logging providers unless told to keep them, so
  the OpenTelemetry logger provider that Azure Monitor exports from gets no
  log records.
- The Serilog OpenTelemetry sink sends OTLP to its default endpoint, not to
  Azure Monitor.
- Requests and dependencies still arrive, which hides the gap.
- The same lines sit in the container console log table
  (`ContainerAppConsoleLogs_CL`).

## How to detect it

One query per environment. Zero rows over a long window means no log reaches
Application Insights:

```kusto
traces
| where timestamp > ago(90d)
| summarize rows = count(), newest = max(timestamp)
```

## Fixes

1. Point the alert queries at the console log table (what we did):

   ```kusto
   ContainerAppConsoleLogs_CL
   | where ContainerAppName_s == "<app name>"
   | where Log_s has "<text the alert looks for>"
   ```

   The rule is then scoped to the Log Analytics workspace instead of the
   Application Insights resource.

2. Keep the other logging providers (not tested in that project). The flag is
   on the overload that takes a configuration delegate:

   ```csharp
   builder.Host.UseSerilog(
       (context, services, configuration) => configuration
           .ReadFrom.Configuration(context.Configuration)
           .WriteTo.Console(),
       writeToProviders: true);
   ```

   This doubles log ingestion if the console log is collected as well.

## Rule of thumb

Before trusting a log alert, confirm that the table it queries holds matching
rows from a known past occurrence. A rule that deploys is not a rule that can
fire.
