open-telemetry / opentelemetry-dotnet

The OpenTelemetry .NET Client
https://opentelemetry.io
Apache License 2.0
3.23k stars 765 forks source link

Log level per exporter? #5766

Closed gintarasd-bentley closed 3 months ago

gintarasd-bentley commented 3 months ago

What is the question?

Hello, is there a way to configure log levels per exporter?

Additional context

We want to send:

For ASP.NET Logging -> Logging provider, log levels can be configured like so:

{
  "Logging": {
    "ProviderA": {
      "LogLevel": {
        "Default": "Information"
      }
    },
    "ProviderB": {
      "LogLevel": {
        "Default": "Error"
      }
    }
  }
}

For OpenTelemetry logging provider -> Exporter however, I could not find anything similar.

cijothomas commented 3 months ago

Not easily possible. ILogger filtering mechanism is per provider. Entire OpenTelemetry is one provider from ILogger perspective. Further filtering is possible in OpenTelemetry, by wrapping exporting processors with a custom FilteringProcessor. There are no examples on how to do that today.

You may take a look at the example from here: https://github.com/Azure/azure-sdk-for-net/pull/44745#discussion_r1655622219 (and potentially contribute it back to the contrib repo, if you have bandwidth!).

There was a proposal to make this easier https://github.com/open-telemetry/opentelemetry-dotnet/pull/5282 but that did not proceed much.

gintarasd-bentley commented 3 months ago

Azure monitor is one of the exporters we were having trouble with, ended up using the old appinsights sdk so we have a separate configurable logging provider, thanks!