Skip to main content

arolariu.Backend.Common.Telemetry.Logging

arolariu.Backend.Common

arolariu.Backend.Common.Telemetry.Logging Namespace

Classes

LoggingExtensions Class

Provides extension methods for configuring OpenTelemetry logging with Azure Monitor integration. This class sets up structured logging with automatic export to Azure Application Insights.

public static class LoggingExtensions

Inheritance System.Object 🡒 LoggingExtensions

Example

// Usage in Program.cs
var builder = WebApplication.CreateBuilder(args);
builder.AddOTelLogging();

Remarks

This extension configures: - OpenTelemetry logging providers for structured log collection - Azure Monitor exporter for cloud-based log aggregation - Console exporter for local debugging scenarios - Scope and formatted message inclusion for detailed context

Methods

LoggingExtensions.AddOTelLogging(this WebApplicationBuilder) Method

Configures OpenTelemetry logging with Azure Monitor export capabilities. This method sets up structured logging that automatically exports to Azure Application Insights and includes console output during debugging.

public static void AddOTelLogging(this Microsoft.AspNetCore.Builder.WebApplicationBuilder builder);

Parameters

builder Microsoft.AspNetCore.Builder.WebApplicationBuilder

The Microsoft.AspNetCore.Builder.WebApplicationBuilder to configure with OpenTelemetry logging.

Exceptions

System.ArgumentNullException
Thrown when builder is null.

Remarks

This method configures: - Formatted message inclusion for readable log entries - Scope inclusion to capture logging context and correlation - Console exporter when debugger is attached for development - Azure Monitor exporter with Application Insights integration - Managed Identity authentication for secure cloud access

// was this page useful?