Use discount code 3YEARS for a 10% discount on my Essentials Course Bundle: 🤍nickchapsas.com/p/from-zero-to-hero-course-bundle Become a Patreon and get source code access: 🤍🤍patreon.com/nickchapsas Hello everybody I'm Nick and in this video I will show how you can do high-performance logging in .NET. Logging is something that can be abused very easily but thankfully the latest versions of .NET have added a couple of ways to perform logging that is as efficient as possible. Don't forget to comment, like and subscribe :) Social Media: Follow me on GitHub: 🤍bit.ly/ChapsasGitHub Follow me on Twitter: 🤍bit.ly/ChapsasTwitter Connect on LinkedIn: 🤍bit.ly/ChapsasLinkedIn Keep coding merch: 🤍keepcoding.shop #csharp #dotnet #logging
Im having problems using this with serilog since I cant use Destructuring "@" for my objects. do you know a solution for this?
Thanks for the video. I was curious if the extension method was part of the "magic" since you implemented it that was and so does Microsoft in the documentation. Ran my own benchmarks and unless I'm missing something there is no appreciable benefit from implementing the extension method vs. calling the action directly. This is good for me as the extension method doesn't really make sense for one off log calls (ie: request logging in an IMiddleware).
| Method | Logger | Mean | Error | StdDev | Median | Ratio | RatioSD | Gen 0 | Allocated |
|------------------------ |------------ |-------------:|-----------:|-----------:|-------------:|------:|--------:|-------:|----------:|
| LoggerMessage_Action | Serilog [W] | 8.290 ns | 0.1812 ns | 0.1779 ns | 8.212 ns | 0.09 | 0.00 | - | - |
| LoggerMessage_Extension | Serilog [W] | 8.092 ns | 0.1143 ns | 0.1069 ns | 8.071 ns | 0.09 | 0.00 | - | - |
| Logger_LogInformation | Serilog [W] | 92.322 ns | 1.7557 ns | 1.7243 ns | 91.717 ns | 1.00 | 0.00 | 0.0153 | 64 B |
nunca desista do seu canal vc tem potencial
adorei muitobom adoro seus videos sao especiais
Why not just set the LoggerAdapter property to null and use LoggerAdapter?.LogInformation(). Or use polymorphism and have a NullLogger where calling LoggerAdapter.LogInformation() does nothing?
Back in the old days, I learned to do logging with the Debug class. The advantage I was told about was that any line made with that would simply not be there in the Release version. Althought this doesn't allow me to turn on debug logging in a Release environment, and I only have 2 levels, it is by far the most efficient way to get rid of debug logging in an Release environment.
I like knowing my relics.
Nick, I have a doubt in this video and in the previous about logging adapter, you say adapter without if on the benchmark but you have the if in the implementation.. 🤷♂️
Nice video, it's surprising that something simple as logging is taken as-is without necessarily taking into consideration this kind of thing.
Your channel and RawCoding have made me a better .NET developer for sure. Great stuff
is there any git hub repo for this project?
Hey nick, your videos are great..! In one of your videos you showed how to inject a class that inherits an interface and also same interface is injected in constructor.
I have a similar situation. Can you help me find that video. It would be great 👍. Thanks..!
If you don’t log, you can’t do it wrong ;)
can you create courses using mongodb .. thanks
What is that LoggerMessageAttribute? Where can I find that?
How did you get your partial static void method to work, Visual Studio complains about CS8795 Partial method <method name> must have an implementation part because it has accessibility modifiers? Great video by the way.
Thank for the video but I'm actually a little lost. You demonstrate the best way to do it, but how do you implement it in a project ? When you log, for exemple, methods, they have not always the same parameters. So maybe I miss something but each time you want log a new method with new parameters or with a different log message, you need to create a new method with LoggerMessage Attribut ?
Nice vid. Your font is too big, we can't see all the code
Didn't think I could be surprised by a video about logging, but there you are