Logging with scopes #9406
Replies: 4 comments
-
What do you expect to see when there is a scope? There aren't separate events when a scope is started or stopped. If you want log entries when a scope is started or stopped you'll need to add them with the scope. A scope has attributes and those attributes are automatically added to any logs inside the scope. For example, the log below is making a HTTP request. But the log entry includes attributes from the parent HTTP request scope (ConnectionId, RequestId, RequestPath). |
Beta Was this translation helpful? Give feedback.
-
In my case, I use a proxy class to take care of basic logging for my DataAccess classes.
The thing is I searched up and down but did not find the scope. During debugging, I can check that the scope is active. |
Beta Was this translation helpful? Give feedback.
-
I think what you're asking for isn't possible because the dashboard doesn't have that data. Name/value properties from the scope are added to the log entry when data is serialized to OTLP and sent to the dashboard, but that's it. You could ask on https://github.com/open-telemetry/opentelemetry-dotnet about sending more data, but OTLP is designed to be generic to OpenTelemetry and isn't customized to support features specific to .NET logging. |
Beta Was this translation helpful? Give feedback.
-
Yep, I would switch to activities instead of using logging scopes if that's the experience you want. |
Beta Was this translation helpful? Give feedback.
-
Is there an existing issue for this?
Describe the bug
When using scopes, the scopes are not visible in the logs.
Expected Behavior
If scopes are used, the scopes should be visible in the logs.
Steps To Reproduce
use
_logger.BeginScope
to create a scope and log something
Exceptions (if any)
No response
.NET Version info
No response
Anything else?
No response
Beta Was this translation helpful? Give feedback.
All reactions