Logging, Monitoring & Debugging
Why Logging, Monitoring & Debugging?
Logging Levels
Standard Log Levels
LogLevel.Trace // Very detailed (e.g., method entry/exit)
LogLevel.Debug // Debugging information
LogLevel.Information // General informational messages
LogLevel.Warning // Unexpected but recoverable events
LogLevel.Error // Errors that don't stop the application
LogLevel.Critical // Fatal errors that crash the applicationWhen to Use Each Level
Built-in Logging (ILogger)
Basic Setup
Configuration (appsettings.json)
Basic Usage
Structured Logging with Serilog
Installation
Setup
Configuration (appsettings.json)
Structured Logging Examples
Log Enrichers
Serilog Sinks
Application Insights
Setup
Configuration
Custom Telemetry
Custom Telemetry Initializer
Health Checks
Setup
Custom Health Check
Debugging Techniques
1. Visual Studio Debugging
2. Diagnostic Logging
3. Exception Handling & Logging
4. Request/Response Logging Middleware
Performance Monitoring
1. Custom Metrics
2. Action Filters for Timing
Best Practices
1. Use Structured Logging
2. Don't Log Sensitive Data
3. Use Log Scopes
4. Appropriate Log Levels
5. Performance Considerations
Monitoring Dashboard Example
Custom Health Check Dashboard
Common Debugging Scenarios
1. Tracking Down Null Reference Exception
2. Performance Bottleneck Investigation
Quick Reference Checklist
Logging Checklist
Monitoring Checklist
Debugging Checklist
Last updated