Skip to content

Commit

Permalink
Better warning about ilogger setup in asp.net core (#4188)
Browse files Browse the repository at this point in the history
  • Loading branch information
cijothomas committed Feb 14, 2023
1 parent fbbc57a commit 07bbdea
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions docs/logs/getting-started/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,18 @@ instance, which is then used to do the logging. The log is sent to the
`OpenTelemetryLoggerProvider`, which is configured to export logs to
`ConsoleExporter`. `ConsoleExporter` simply displays it on the console.

Adding logging providers, obtaining `ILogger` instance, etc. could be done
differently based on the application type. For example, [Logging in ASP.NET
Core](https://docs.microsoft.com/aspnet/core/fundamentals/logging#logging-providers)
shows how to do logging in ASP.NET Core, which is also demonstrated in the
[OpenTelemetry Example ASP.NET Core
application](../../../examples/AspNetCore/Program.cs)
> **Note**
> Certain types of applications (e.g. [ASP.NET
Core](https://learn.microsoft.com/aspnet/core) and [.NET
Worker](https://learn.microsoft.com/dotnet/core/extensions/workers)) have an
`ILogger` based logging pipeline set up by default. In such apps, enabling
OpenTelemetry should be done by adding OpenTelemetry as a provider to the
*existing* logging pipeline, and users should not create a new `LoggerFactory`
(which sets up a totally new logging pipeline). Also, obtaining `ILogger`
instance could be done differently as well. See [Example ASP.NET Core
application](../../../examples/AspNetCore/Program.cs) for an example which shows
how to add OpenTelemetry to the logging pipeline already setup by the
application.

## Learn more

Expand Down

0 comments on commit 07bbdea

Please sign in to comment.