Skip to main content

Posts

Showing posts from October, 2020

Azure Application Insights Logging and EF Core in a Domain Driven Design

Logging is one of the core pillars of application development. .NET Core has fantastic support for rich contextual logging which spans across distributed system using its Activity API . Azure Application Insights SDK offers extensive logging out of the box without writing a single line of code. Just wire up the SDK and you are good to go. However there may be situations where you may want more fine grained control over the logging experience. Fortunately, its as simple as writing: Activity activity = new Activity("Test Message"); var operation = telemetryClient.StartOperation<DependencyTelemetry>(activity); This TelemetryClient is injected in your application when you wire up Application Insights. services.AddApplicationInsightsTelemetry(options => options.InstrumentationKey = "YOUR_AI_KEY"); This works seamlessly till you hit the road block of Domain Driven Design and Entity Framework Core. In DDD, entities represent a real-world business object and perf