High-performance logging in .NET, the proper way

42935
86
1484
13.01.2022
Nick Chapsas

Nick Chapsas

14173719
145000
293
29.11.2011
GB
Описание видео:

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

Кадры из видео
High-performance logging in .NET, the proper way
High-performance logging in .NET, the proper way
High-performance logging in .NET, the proper way
High-performance logging in .NET, the proper way
Тэги из видео
Комментарии пользователей:
Pedro Ferreira
2022-07-22 14:45:13

Hey Nick,
Im having problems using this with serilog since I cant use Destructuring "@" for my objects. do you know a solution for this?

Q L
2022-03-21 09:45:40

WTF

Cory Charlton
2022-02-19 09:56:24

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 |

Vinicius Vassão
2022-02-17 03:12:47

nunca desista do seu canal vc tem potencial

Vinicius Vassão
2022-02-17 03:12:30

adorei muitobom adoro seus videos sao especiais
abs

Brent Jacobs
2022-02-16 08:43:49

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?

Frank Roos
2022-02-03 17:37:56

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.

Tomas Barrera
2022-01-25 23:22:25

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.. 🤷‍♂️

davilinkicefire
2022-01-17 21:47:03

Nice video, it's surprising that something simple as logging is taken as-is without necessarily taking into consideration this kind of thing.

Joseph Izang
2022-01-17 17:38:22

Your channel and RawCoding have made me a better .NET developer for sure. Great stuff

Boopal S
2022-01-17 17:03:29

is there any git hub repo for this project?

neelesh bodgal
2022-01-16 17:46:59

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..!

John Peter
2022-01-15 19:35:19

If you don’t log, you can’t do it wrong ;)

Moataz Al-ALi
2022-01-14 23:35:07

can you create courses using mongodb .. thanks

Yevheniy Tymchishin
2022-01-14 23:35:06

What is that LoggerMessageAttribute? Where can I find that?

Steve Higgin
2022-01-14 16:34:36

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.

Rémi
2022-01-14 08:37:43

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 ?

John Cerpa
2022-01-14 02:50:02

Nice vid. Your font is too big, we can't see all the code

Wojciech Wilimowski
2022-01-14 00:26:04

Didn't think I could be surprised by a video about logging, but there you are

Что ищут прямо сейчас
короче говоря ван ту Abraham kırgın çiçekler meral build yi sun shin skywalker xəyal hüseynov gaplashamiz boku no hero academia peace sign canción de kimberly localiza самые выгодные видеокарты для майнинга ЖУМА МАЪРУЗАСИ РАМАЗОН богатый ботан Balboa котэ дом маринетт Official Visualizer aaj ka rashifal বাংলা শস্য বীমা ফর্ম ROQ 'N Rolla Music save lokir
Похожие видео
05.01.2022
You are doing .NET logging wrong. Let's fix it

You are doing .NET logging wrong. Let's fix it

30.03.2022
Writing C# without allocating ANY memory

Writing C# without allocating ANY memory

10.11.2019
C# Logging with Serilog and Seq - Structured Logging Made Easy

C# Logging with Serilog and Seq - Structured Logging Made Easy

15.11.2021
Logging, Monitoring, and Telemetry in ASP.NET Core 6 with Serilog

Logging, Monitoring, and Telemetry in ASP.NET Core 6 with Serilog

14.01.2022
My .NET backend developer roadmap for 2022

My .NET backend developer roadmap for 2022

10.06.2021
Making async code run faster in C#

Making async code run faster in C#

22.08.2019
Logging in .NET Core 3.0 and Beyond - Configuration, Setup, and More

Logging in .NET Core 3.0 and Beyond - Configuration, Setup, and More

19.08.2020
LOGGING in ASP.NET Core | Getting Started With ASP.NET Core Series

LOGGING in ASP.NET Core | Getting Started With ASP.NET Core Series

31.08.2022
How IEnumerable can kill your performance in C#

How IEnumerable can kill your performance in C#

14.07.2022
How to implement Serilog in .NET Core 6.0 | Enable logging globally | Log using dependency injection

How to implement Serilog in .NET Core 6.0 | Enable logging globally | Log using dependency injection

08.09.2020
8 await async mistakes that you SHOULD avoid in .NET

8 await async mistakes that you SHOULD avoid in .NET

13.03.2022
Stop using String Interpolation when Logging in .NET

Stop using String Interpolation when Logging in .NET

24.09.2022
The RIGHT way to deal with Date and Time in C#

The RIGHT way to deal with Date and Time in C#

07.09.2022
The CORRECT way to implement Retries in .NET

The CORRECT way to implement Retries in .NET

09.07.2021
What is Span in C# and why you should be using it

What is Span in C# and why you should be using it

09.09.2022
The fastest way to iterate a List in C# is NOT what you think

The fastest way to iterate a List in C# is NOT what you think