This series is a collection of knowledge about ASP .NET Core. It just is my notes.
Part 10: Make an HTTP Request.
Part 12: Authentication and Authorization.
The log is one of the approaches to troubleshoot the application. So, Don't forget to implement the logs for your application.
- Log level
| LogLevel | Value | Method | Description |
|---|---|---|---|
| Trace | 0 | LogTrace | Contain the most detailed messages. These messages may contain sensitive app data. These messages are disabled by default and should not be enabled in production. |
| Debug | 1 | LogDebug | For debugging and development. Use caution in production due to the high volume. |
| Information | 2 | LogInformation | Tracks the general flow of the app. May have long-term value. |
| Warning | 3 | LogWarning | For abnormal or unexpected events. Typically includes errors or conditions that don't cause the app to fail. |
| Error | 4 | LogError | For errors and exceptions that cannot be handled. These messages indicate a failure in the current operation or request, not an app-wide failure. |
| Critical | 5 | LogCritical | For failures that require immediate attention. Examples: data loss scenarios, out of disk space. |
| None | 6 | Specifies that a logging category should not write any messages. |
- Built-in logging provider
- Third-party logging provider
- NLog
- Serilog
- How to use AppInsight and Telemetry
- Create an AppInsight resource via Azure Portal.
- Get the information of instrumentation key or connection string
- Add Nuget package
- Microsoft.ApplicationInsights.AspNetCore
- ConfigureService
- Important: some Azure region requires a connection string instead of Instrumentation key
- Note: You can also configure AppInsight following these recommendations
- Use TelemetryClient
- The best practice is to create a wrapper class for TelemetryClient


