SlideShare a Scribd company logo
Logging tracing and metrics in .NET Core and Azure - dotnetdays 2020
DevOps needs monitoring
https://docs.microsoft.com/en-us/azure/architecture/checklist/dev-ops#monitoring
Loops in DevOps practices
Application performance monitoring
Cloud applications are complex
Collect and correlate
instrumentation data
Sentry.ioRaygun.io RunscopeNewRelic AlertSite DataDogAppMetrics Azure Monitor
Cloud Application
Azure Resources
Azure Monitor
Azure Subscription
Azure Tenant
Azure Monitor Logs
Applications in Azure
Azure Monitor
Metrics
Collect Monitor
Application instrumentation
Logging
Tracing
Metrics
Health
Dashboards
Alerting
Analytics
Profiling
Metrics
streaming
Choosing correct type of instrumentation
Log
• What
happened?
• Errors and
warnings and
state changes
• Important
state changes
worth
registering
• Always logged
Trace
• How did it
happen?
• Circumstantial
data for
following flow
• Available on
request
• Publish/
subscribe
model mostly
• High volume
Metric
• How much is
happening?
• Numerical
information of
events
• Suitable for
aggregation
and trends
Health
• How is it
doing?
• Information
indicating
health status
• Internally
determined by
component
Audit
• Who made it
happen?
• Data
regarding
actions
performed by
someone
• Always
• Security and
identity
related
• Proof for non-
repudiability
Logging in .NET Core
Leveraging CoreFX libraries
for logging
Logging
Persisting important events in a log
Built-in since .NET Core 1.0
Logging providers
Host.CreateDefaultBuilder(args)
.ConfigureLogging((context, builder) =>
{
// Log providers
builder.AddApplicationInsights(options =>
{
options.IncludeScopes = true;
options.TrackExceptionsAsExceptionTelemetry = true;
});
builder.AddConsole(options => {
options.Format = ConsoleLoggerFormat.Systemd;
});
builder.AddDebug();
builder.AddTraceSource(source.Switch,
new ApplicationInsightsTraceListener());
.NET Core * Added by default
NullLoggerProvider
BatchingLoggerProvider
ConsoleLoggerProvider *
DebugLoggerProvider *
EventLogLoggerProvider *
EventSourceLoggerProvider *
TraceSourceLoggerProvider *
ASP.NET Core
ApplicationInsightsLoggerProvider
AzureAppServicesFile
AzureAppServicesBlob
Third party
NLogLogger
Seq
Log4Net
Loggr
LoggerFactory and logger instances
LoggerFactory
LogCritical
LogError
LogWarning
LogDebug
LogTrace
LogInformation
ILogger<T>
Log severity levels and categories
Hierarchical structure
Microsoft
Microsoft.Hosting.Lifetime
Determined from T in ILogger<T>
public enum LogLevel
{
Trace = 0,
Debug = 1,
Information = 2,
Warning = 3,
Error = 4,
Critical = 5,
None = 6
}
ILogger<LeaderboardController>
namespace LeaderboardWebApi.Controllers {
public class LeaderboardController : Controller { … }
}
"LeaderboardWebApi.Controllers.LeaderboardController"
Separate configuration
for specific providers
General configuration
for all providers
Log filters
Filter log messages
appsettings.json
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
},
"Console": {
"LogLevel": { … }
"IncludeScopes": true
}
}
ILogger<T>
Demo
Logging 101
Quantum physics applied to logging
Duality of log messages
Semantic logging (aka structured logging)
Message templates
Popular log providers supporting semantic logging
// Placeholders in template become queryable custom data
logger.LogInformation("Searching with {SearchLimit} results.", limit);
Demo
Structured logging using Seq
Scopes
Groups a set of logical operations
Requires setting options to include scope for provider
logging.AddConsole(options => options.IncludeScopes = true);
using (logger.BeginScope("Message attached to logs created in the using block"))
{
logger.LogInformation(LoggingEvents.NewHighScore, “New high score {score}", highScore);
var game = gameRepository.Find(gameId);
if (game == null)
{
logger.LogWarning(LoggingEvents.GameNotFound, "GetById({game}) not found", gameId);
return NotFound();
}
}
Logging guidance
Separation of concerns
Choose your log severity level carefully
Use event IDs when possible
Log messages are not for UI
When in doubt, be generous on logging
Alternative logging solutions
Serilog
Replaces built-in logging system
More functionality
Serilog
Tracing
Familiar concepts and API
from .NET Framework
Diagnostics Trace
High volume noise to follow flow
Publish/subscribe
System.Diagnostics namespace
Trace and TraceSource entrypoints
Uses activities under the cover
Tracing infrastructure
Trace
TraceData
TraceEvent
TraceInformation
TraceTransfer
TraceError
TraceWarning
TraceInformation
Write(If)
WriteLine(If)
TraceSource
Activities
Ambient contextual data
Activity.Current
Used for correlating events
Parent/Child relationship
var activity = new Activity("SearchEngine.Run");
activity.SetStartTime(DateTime.Now);
activity.Start();
activity.Track...();
Available trace listeners
Namespace Class .NET version
System.Diagnostics DefaultTraceListener Core 1.0+
TextWriterTraceListener Core 1.0+
EventLogTraceListener Core 3.0
ConsoleTraceListener Core 3.0
DelimitedListTraceListener Core 1.0+
XmlWriterTraceListener Core 3.0
EventSchemaTraceListener .NET FX 3.5+
System.Diagnostics.Eventing EventProviderTraceListener .NET FX 3.5+
System.Web IisTraceListener .NET FX 2.0+
WebPageTraceListener .NET FX 2.0+
Microsoft.VisualBasic.Logging FileLogTraceListener .NET FX 2.0+
From .NET Framework 2.0 to .NET Core 3.0
Demo
Tracing 101
Health checks
Indicating health status
from .NET Core
Health monitoring
services
.AddHealthChecks()
.AddCheck("sync", () => … )
.AddAsyncCheck("async", async () => … )
.AddCheck<SqlConnectionHealthCheck>("SQL")
.AddCheck<UrlHealthCheck>("URL");
ASP.NET Core application
/health
DefaultHealthCheckService
Health check publishers
Pushes out health
info periodically
Options
ASP.NET Core application
DefaultHealthCheckService
HealthCheckPublisher
HostedService
IEnumerable<IHealthCheckPublisher>
services.AddHealthChecks()
.AddApplicationInsightsPublisher()
.AddPrometheusGatewayPublisher(
"http://pushgateway:9091/metrics",
"pushgateway") IHealthCheckPublisher
Probing containers to check for availability and health
Readiness and liveness
Kubernetes node
Kubernetes node
Kubernetes nodes
Containers
Readiness
Liveliness
Implementing readiness and liveliness
1. Add health checks with tags
2. Register multiple endpoints
with filter using
Options predicate
/api/v1/…
/health
/health/ready
/health/lively
app.UseHealthChecks("/health/ready",
new HealthCheckOptions() {
Predicate = reg => reg.Tags.Contains("ready")
});
services.AddHealthChecks()
.AddCheck<CircuitBreakerHealthCheck>(
"circuitbreakers",
tags: new string[] { "ready" });
app.UseHealthChecks("/health/lively",
new HealthCheckOptions() {
Predicate = _ => true
});
Demo
Health checks and monitoring in .NET Core
Application Insights
Metrics, monitoring, querying
and analyzing your
application
DevOps and loops
Azure Application Insights
Extensible Application Performance Monitor
Application Insights in .NET Core
Logging and tracing
builder.AddApplicationInsights(options => {
options.TrackExceptionsAsExceptionTelemetry = true;
options.IncludeScopes = true;
});
Telemetry
TelemetryClient StartOperation TrackEvent
Trace.Listeners.Add(new ApplicationInsightsTraceListener());
services.AddApplicationInsightsTelemetry(options =>
{
options.DeveloperMode = true;
});
Demo
DevOps needs monitoring
https://docs.microsoft.com/en-us/azure/architecture/checklist/dev-ops#monitoring
Questions and Answers
Resources
https://docs.microsoft.com/en-us/aspnet/core/fundamentals/logging/?view=aspnetcore-3.1
https://docs.microsoft.com/en-us/azure/architecture/patterns/health-endpoint-monitoring
https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/health-checks
https://dev.applicationinsights.io/apiexplorer/metrics

More Related Content

What's hot (20)

PDF
Getting Started Monitoring with Prometheus and Grafana
Syah Dwi Prihatmoko
 
PPTX
Part 2 -Deep Dive into the new features of Sharepoint Online and OneDrive for...
Vignesh Ganesan I Microsoft MVP
 
PPTX
Logging using ELK Stack for Microservices
Vineet Sabharwal
 
PDF
Introduction to Stream Processing
Guido Schmutz
 
PDF
Apache Flink internals
Kostas Tzoumas
 
PDF
Building Dynamic Pipelines in Azure Data Factory (SQLSaturday Oslo)
Cathrine Wilhelmsen
 
PDF
Batch and Stream Graph Processing with Apache Flink
Vasia Kalavri
 
PPTX
Introduction to Apache Flink
mxmxm
 
PDF
Azure Data Factory v2
inovex GmbH
 
PPT
Monitoring using Prometheus and Grafana
Arvind Kumar G.S
 
PDF
Intro to databricks delta lake
Mykola Zerniuk
 
PPTX
ELK Elasticsearch Logstash and Kibana Stack for Log Management
El Mahdi Benzekri
 
PDF
Distributed Tracing
distributedtracing
 
PDF
Delta Lake OSS: Create reliable and performant Data Lake by Quentin Ambard
Paris Data Engineers !
 
PDF
Nifi
Julio Castro
 
PDF
Introduction to Azure Data Factory
Slava Kokaev
 
PDF
Observability for Data Pipelines With OpenLineage
Databricks
 
PPTX
Real-Time Data Flows with Apache NiFi
Manish Gupta
 
PPTX
Automated API pentesting using fuzzapi
Abhijeth D
 
PPTX
Mendix Accelerates the Software Lifecycle
Mendix
 
Getting Started Monitoring with Prometheus and Grafana
Syah Dwi Prihatmoko
 
Part 2 -Deep Dive into the new features of Sharepoint Online and OneDrive for...
Vignesh Ganesan I Microsoft MVP
 
Logging using ELK Stack for Microservices
Vineet Sabharwal
 
Introduction to Stream Processing
Guido Schmutz
 
Apache Flink internals
Kostas Tzoumas
 
Building Dynamic Pipelines in Azure Data Factory (SQLSaturday Oslo)
Cathrine Wilhelmsen
 
Batch and Stream Graph Processing with Apache Flink
Vasia Kalavri
 
Introduction to Apache Flink
mxmxm
 
Azure Data Factory v2
inovex GmbH
 
Monitoring using Prometheus and Grafana
Arvind Kumar G.S
 
Intro to databricks delta lake
Mykola Zerniuk
 
ELK Elasticsearch Logstash and Kibana Stack for Log Management
El Mahdi Benzekri
 
Distributed Tracing
distributedtracing
 
Delta Lake OSS: Create reliable and performant Data Lake by Quentin Ambard
Paris Data Engineers !
 
Introduction to Azure Data Factory
Slava Kokaev
 
Observability for Data Pipelines With OpenLineage
Databricks
 
Real-Time Data Flows with Apache NiFi
Manish Gupta
 
Automated API pentesting using fuzzapi
Abhijeth D
 
Mendix Accelerates the Software Lifecycle
Mendix
 

Similar to Logging tracing and metrics in .NET Core and Azure - dotnetdays 2020 (20)

PPTX
Logging, tracing and metrics: Instrumentation in .NET 5 and Azure
Alex Thissen
 
PPTX
What is going on - Application diagnostics on Azure - TechDays Finland
Maarten Balliauw
 
PPTX
What is going on? Application Diagnostics on Azure - Copenhagen .NET User Group
Maarten Balliauw
 
PPTX
ASP.NET Core For The Agile Enterprise
Dennis Moon
 
PPTX
Back-2-Basics: Exception & Event Instrumentation in .NET
David McCarter
 
PPTX
Back-2-Basics: Exception & Event Instrumentation in .NET
David McCarter
 
PPTX
The Incremental Path to Observability
Emily Nakashima
 
PPTX
Observability for Application Developers (1)-1.pptx
OpsTree solutions
 
PPTX
ReflectInsight - Let your application speak volume
Callon Campbell
 
PPT
Mastering IntelliTrace in Development and Production
Sasha Goldshtein
 
PDF
Cloud brew henry been - logging instrumentation dashboards alerts
Henry Been
 
PPTX
Deep-Dive to Application Insights
Gunnar Peipman
 
PDF
Azure Application insights - An Introduction
Matthias Güntert
 
PDF
Serverless computing henry been - logging instrumentation dashboards alerts
Henry Been
 
PPTX
The Ultimate Logging Architecture - You KNOW you want it!
Michele Leroux Bustamante
 
PPTX
Diagnosing issues in your ASP.NET applications in production with Visual Stud...
Microsoft Developer Network (MSDN) - Belgium and Luxembourg
 
PDF
Why Monitoring and Logging are Important in DevOps.pdf
Datacademy.ai
 
PDF
Un-broken Logging - TechnologyUG - Leeds - Matthew Skelton
Skelton Thatcher Consulting Ltd
 
PPTX
Campus days 2013 - Instrumentation
Anders Lybecker
 
PDF
Different monitoring options for cloud native integration solutions
BizTalk360
 
Logging, tracing and metrics: Instrumentation in .NET 5 and Azure
Alex Thissen
 
What is going on - Application diagnostics on Azure - TechDays Finland
Maarten Balliauw
 
What is going on? Application Diagnostics on Azure - Copenhagen .NET User Group
Maarten Balliauw
 
ASP.NET Core For The Agile Enterprise
Dennis Moon
 
Back-2-Basics: Exception & Event Instrumentation in .NET
David McCarter
 
Back-2-Basics: Exception & Event Instrumentation in .NET
David McCarter
 
The Incremental Path to Observability
Emily Nakashima
 
Observability for Application Developers (1)-1.pptx
OpsTree solutions
 
ReflectInsight - Let your application speak volume
Callon Campbell
 
Mastering IntelliTrace in Development and Production
Sasha Goldshtein
 
Cloud brew henry been - logging instrumentation dashboards alerts
Henry Been
 
Deep-Dive to Application Insights
Gunnar Peipman
 
Azure Application insights - An Introduction
Matthias Güntert
 
Serverless computing henry been - logging instrumentation dashboards alerts
Henry Been
 
The Ultimate Logging Architecture - You KNOW you want it!
Michele Leroux Bustamante
 
Diagnosing issues in your ASP.NET applications in production with Visual Stud...
Microsoft Developer Network (MSDN) - Belgium and Luxembourg
 
Why Monitoring and Logging are Important in DevOps.pdf
Datacademy.ai
 
Un-broken Logging - TechnologyUG - Leeds - Matthew Skelton
Skelton Thatcher Consulting Ltd
 
Campus days 2013 - Instrumentation
Anders Lybecker
 
Different monitoring options for cloud native integration solutions
BizTalk360
 
Ad

More from Alex Thissen (18)

PPTX
Go (con)figure - Making sense of .NET configuration
Alex Thissen
 
PPTX
Health monitoring and dependency injection - CNUG November 2019
Alex Thissen
 
PPTX
Architecting .NET solutions in a Docker ecosystem - .NET Fest Kyiv 2019
Alex Thissen
 
PPTX
I dont feel so well. Integrating health checks in your .NET Core solutions - ...
Alex Thissen
 
PPTX
It depends: Loving .NET Core dependency injection or not
Alex Thissen
 
PPTX
Overview of the new .NET Core and .NET Platform Standard
Alex Thissen
 
PPTX
Exploring Microservices in a Microsoft Landscape
Alex Thissen
 
PPTX
How Docker and ASP.NET Core will change the life of a Microsoft developer
Alex Thissen
 
PPTX
Visual Studio Productivity tips
Alex Thissen
 
PPTX
Exploring microservices in a Microsoft landscape
Alex Thissen
 
PPTX
Asynchronous programming in ASP.NET
Alex Thissen
 
PPTX
Visual Studio 2015 experts tips and tricks
Alex Thissen
 
PPTX
ASP.NET 5 - Microsoft's Web development platform reimagined
Alex Thissen
 
PPTX
MVC 6 - the new unified Web programming model
Alex Thissen
 
PPTX
//customer/
Alex Thissen
 
PPTX
ASP.NET vNext
Alex Thissen
 
PPTX
Run your Dockerized ASP.NET application on Windows and Linux!
Alex Thissen
 
PPTX
.NET Core: a new .NET Platform
Alex Thissen
 
Go (con)figure - Making sense of .NET configuration
Alex Thissen
 
Health monitoring and dependency injection - CNUG November 2019
Alex Thissen
 
Architecting .NET solutions in a Docker ecosystem - .NET Fest Kyiv 2019
Alex Thissen
 
I dont feel so well. Integrating health checks in your .NET Core solutions - ...
Alex Thissen
 
It depends: Loving .NET Core dependency injection or not
Alex Thissen
 
Overview of the new .NET Core and .NET Platform Standard
Alex Thissen
 
Exploring Microservices in a Microsoft Landscape
Alex Thissen
 
How Docker and ASP.NET Core will change the life of a Microsoft developer
Alex Thissen
 
Visual Studio Productivity tips
Alex Thissen
 
Exploring microservices in a Microsoft landscape
Alex Thissen
 
Asynchronous programming in ASP.NET
Alex Thissen
 
Visual Studio 2015 experts tips and tricks
Alex Thissen
 
ASP.NET 5 - Microsoft's Web development platform reimagined
Alex Thissen
 
MVC 6 - the new unified Web programming model
Alex Thissen
 
//customer/
Alex Thissen
 
ASP.NET vNext
Alex Thissen
 
Run your Dockerized ASP.NET application on Windows and Linux!
Alex Thissen
 
.NET Core: a new .NET Platform
Alex Thissen
 
Ad

Recently uploaded (19)

PPTX
presentation on legal and regulatory action
raoharsh4122001
 
PPTX
Pastor Bob Stewart Acts 21 07 09 2025.pptx
FamilyWorshipCenterD
 
PDF
Model Project Report_36DR_G&P.pdf for investors understanding
MeetAgrawal23
 
PPTX
AI presentation for everyone in every fields
dodinhkhai1
 
PDF
Leveraging the Power of Jira Dashboard.pdf
siddharthshukla742740
 
PPTX
Presentationexpressions You are student leader and have just come from a stud...
BENSTARBEATZ
 
DOCX
How Digital Marketplaces are Empowering Emerging MedTech Brands
Ram Gopal Varma
 
PDF
Buy Verified Coinbase Accounts — The Ultimate Guide for 2025 (Rank #1 on Goog...
Buy Verified Cash App Accounts
 
PDF
Buy Verified Payoneer Accounts — The Ultimate Guide for 2025 (Rank #1 on Goog...
Buy Verified Cash App Accounts
 
PPTX
BARRIERS TO EFFECTIVE COMMUNICATION.pptx
shraddham25
 
PPTX
some leadership theories MBA management.pptx
rkseo19
 
PPTX
Great-Books. Powerpoint presentation. files
tamayocrisgie
 
PDF
The Family Secret (essence of loveliness)
Favour Biodun
 
PDF
From Draft to DSN - How to Get your Paper In [DSN 2025 Doctoral Forum Keynote]
vschiavoni
 
PDF
The Origin - A Simple Presentation on any project
RishabhDwivedi43
 
PPTX
Inspired by VeinSense: Supercharge Your Hackathon with Agentic AI
ShubhamSharma2528
 
PPTX
STURGEON BAY WI AG PPT JULY 6 2025.pptx
FamilyWorshipCenterD
 
PDF
Committee-Skills-Handbook---MUNprep.org.pdf
SatvikAgarwal9
 
PDF
The Impact of Game Live Streaming on In-Game Purchases of Chinese Young Game ...
Shibaura Institute of Technology
 
presentation on legal and regulatory action
raoharsh4122001
 
Pastor Bob Stewart Acts 21 07 09 2025.pptx
FamilyWorshipCenterD
 
Model Project Report_36DR_G&P.pdf for investors understanding
MeetAgrawal23
 
AI presentation for everyone in every fields
dodinhkhai1
 
Leveraging the Power of Jira Dashboard.pdf
siddharthshukla742740
 
Presentationexpressions You are student leader and have just come from a stud...
BENSTARBEATZ
 
How Digital Marketplaces are Empowering Emerging MedTech Brands
Ram Gopal Varma
 
Buy Verified Coinbase Accounts — The Ultimate Guide for 2025 (Rank #1 on Goog...
Buy Verified Cash App Accounts
 
Buy Verified Payoneer Accounts — The Ultimate Guide for 2025 (Rank #1 on Goog...
Buy Verified Cash App Accounts
 
BARRIERS TO EFFECTIVE COMMUNICATION.pptx
shraddham25
 
some leadership theories MBA management.pptx
rkseo19
 
Great-Books. Powerpoint presentation. files
tamayocrisgie
 
The Family Secret (essence of loveliness)
Favour Biodun
 
From Draft to DSN - How to Get your Paper In [DSN 2025 Doctoral Forum Keynote]
vschiavoni
 
The Origin - A Simple Presentation on any project
RishabhDwivedi43
 
Inspired by VeinSense: Supercharge Your Hackathon with Agentic AI
ShubhamSharma2528
 
STURGEON BAY WI AG PPT JULY 6 2025.pptx
FamilyWorshipCenterD
 
Committee-Skills-Handbook---MUNprep.org.pdf
SatvikAgarwal9
 
The Impact of Game Live Streaming on In-Game Purchases of Chinese Young Game ...
Shibaura Institute of Technology
 

Logging tracing and metrics in .NET Core and Azure - dotnetdays 2020

Editor's Notes

  • #3: https://docs.microsoft.com/en-us/azure/architecture/checklist/dev-ops#monitoring
  • #6: For activity logs and diagnostics: Log Analytics workspace for analyzing Azure Storage for archiving Event Hub for streaming
  • #10: Photo by Matthias Groeneveld from Pexels
  • #18: https://blogs.msdn.microsoft.com/webdev/2017/04/26/asp-net-core-logging/
  • #32: How can restarting a container instance solve health?
  • #35: Photo by Dan Lohmar on Unsplash
  • #40: https://docs.microsoft.com/en-us/azure/architecture/checklist/dev-ops#monitoring