Replies: 8 comments
-
For the main Except that you can use the Sentry API to add more data to the event. Like The protocol has well defined stuff: https://develop.sentry.dev/sdk/event-payloads/ But the integrations such as For more context, check out the Sentry Serilog Sink, and you'll see what we do use. And if you check out the API docs, and the Sentry Docs you'll what possible through the SDK itself (not limited by a logging integration). If you're on a ASP.NET Core app, and don't install the
Similar data for ASP.NET classic (which btw, is moving to a |
Beta Was this translation helpful? Give feedback.
-
Thanks @bruno-garcia for the help/reply. So if i understand you right ...
kewl!
Does this mean that if you just use the
So I like using Serilog because it has the concept of sinks. So (for example) I can get logs going to
and only have one MS So this means I would be missing out on these lovely extra's, for an ASP.NET Core app, because I would only be installed |
Beta Was this translation helpful? Give feedback.
-
Installing
Right, this is how I used Sentry on NuGet Trends too.
You can install both Here you can see how I initialize Serilog before ASP.NET Core so even if the service fails to start, I'll get an event in Sentry: Adding both packages also make sure you can can get Sentry through dependency injection. There's an example of ASP.NET Core and Serilog in this repo, that shows resolving Sentry from the DI container: sentry-dotnet/samples/Sentry.Samples.AspNetCore.Serilog/Program.cs Lines 59 to 69 in ba8e98e In a real world app you're likely taking the dependency via constructor injection, but the sample exists to give you an idea of what's possible, in a simple way/single file. There's more info about |
Beta Was this translation helpful? Give feedback.
-
Hmm. okay! Nice! That would work for Sentry-specific logging (and for constant data) while .. the other sinks would not get this info, though? (more on this, below). Is there any reason why this can't be set TAGS or EXTRA via app settings in a serilog key/value section ? Rational, I try and keep as much configuration stuff out of the code and into the which segways now to dynamic data and Logging Scopes :) does the for example, all our code everywhere will aways use ctor injection of an (note: I prefer to use key/values with my logging scopes...)
Okay, so in this example provided, it looks like some middleware that retrieves an So in the above example, if the middleware detects that the current request is trying to go to route "/throw", then do I need to create a Sentry-scope (the `IHub) and then the MS logger scopes, to make sure all sinks capture this? Feels awkward, if that's the case. In summary, as asked above, is an
Great! this is basically the same code I have in my SimpleHosting nuget library so people don't have to repeat that ceremony every single time they have a new app. 💪🏻 👍🏻 |
Beta Was this translation helpful? Give feedback.
-
Yeah if you call
The ASP.NET Core integration has that: sentry-dotnet/samples/Sentry.Samples.AspNetCore5.Mvc/appsettings.json Lines 22 to 24 in e17703a The Serilog integration itself doesn't have
Hub contains the scope stack + the Sentry client. So it has
On the latest version of the SDK it should be: 2.1.8. Please let me know if not, it would be a bug.
I don't really understand what you said. You don't need to create any scope. That's an optional feature to add some data to a potential event (if something is captured within the scope). When Disposed, the data is also removed (except if an ASP.NET Core request is ongoing btw so we keep it all until the end of the request). The example is just an example. You don't need to get
You don't need to use Here's an example: ANd: sentry-dotnet/samples/Sentry.Samples.Console.Customized/Program.cs Lines 272 to 287 in 58670f6
I hope this clarifies things a bit. |
Beta Was this translation helpful? Give feedback.
-
Phew! There's a lot to grok, so lets see if I understand the replies
Does that sounds about right? |
Beta Was this translation helpful? Give feedback.
-
We could move default tags to
It always had it, but before 2.1.8, on ASP.NET Core (with the scope locked) it didn't keep the values. See #594
Serilog does some funny stuff with ASP.NET Core with regards to logging backend. I see the Sink itself adds some Serilog properties stuff as Extra: I suggest trying stuff out though. |
Beta Was this translation helpful? Give feedback.
-
Great - created an issue (in preparation for a PR) to test this stuff out, etc. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
G'Day 👋🏻 !
With the
Sentry.Serilog
library, is there much features missing .. versus using the mainSentry
library?Context: I prefer to pass
ILogger<T>
all around my application. In myConfigureServices
, I would prefer to just setup Serilog and then log whatever to wherever, via sinks, likeSentry.Serilog
.So if I get an error, I would then log that to Sentry.
Is it safe to assume that the data which is logged to sentry via the Serilog sink is pretty much feature rich as manually using the Serilog library? Like, rich exception information, etc?
Or in other words, if I use the
Sentry.Serilog
library, I would be missing out of the following pieces of data:<something>
<another thing>
Beta Was this translation helpful? Give feedback.
All reactions