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.
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 nothingUseSerilog()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:
traces| where timestamp > ago(90d)| summarize rows = count(), newest = max(timestamp)Fixes
-
Point the alert queries at the console log table (what we did):
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.
-
Keep the other logging providers (not tested in that project). The flag is on the overload that takes a configuration delegate:
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.