Тёмный

7 Serilog Best Practices for Better Structured Logging 

Milan Jovanović
Подписаться 106 тыс.
Просмотров 28 тыс.
50% 1

Опубликовано:

 

27 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 90   
@MilanJovanovicTech
@MilanJovanovicTech 9 месяцев назад
Want to master Clean Architecture? Go here: bit.ly/3PupkOJ Want to unlock Modular Monoliths? Go here: bit.ly/3SXlzSt
@VladyslavHorbachov
@VladyslavHorbachov 9 месяцев назад
This is one of the best videos on your channel. No water, only good explanation and example. Keep doing like this!
@MilanJovanovicTech
@MilanJovanovicTech 9 месяцев назад
Glad you liked it! Working on upping the content quality :)
@AndyMacConnell
@AndyMacConnell 9 месяцев назад
Awesome as always Milan! Thanks for continuing to produce top quality content. I look forward to giving this and Seq a go in future applications I write.
@MilanJovanovicTech
@MilanJovanovicTech 9 месяцев назад
Hope you enjoy it!
@rexlatinae3439
@rexlatinae3439 9 месяцев назад
I must say that you are, in my opinion, the best software developer youtuber and not just in terms of .NET but in general. The way you structure your content, I haven't found that structure anywhere else. From long type videos to short videos and all the way to community, you provide knowledge on every day basis and you are always ready to respond to community that follows your work. Good job, wishing you all the best in the future and can't thank you enough!
@MilanJovanovicTech
@MilanJovanovicTech 9 месяцев назад
Thanks a lot, this means the world to me 😍
@EHBRod13
@EHBRod13 8 месяцев назад
Milan! You're mentioned on page 227 of Apps and Services with .NET 8 by Mark J. Price in the Serilog section! I was reading that to supplement this video.
@MilanJovanovicTech
@MilanJovanovicTech 8 месяцев назад
So cool! Thanks for letting me know. 😁 I actually have a copy of the book, but I missed this.
@prathameshshende4
@prathameshshende4 9 месяцев назад
Hi milan, I have gone almost all your videos regarding architecture and patterns. I really like your videos. I m insist you to create videos series on authorization and authentication. Cookie, JWT and even with SSO and OpenId Connect without using any third party libraries apart from Microsoft itself.
@MilanJovanovicTech
@MilanJovanovicTech 9 месяцев назад
- JWT - ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-4cFhYUK8wnc.html - JWT + Firebase - ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-xBuLWaDcvu0.html - Permission auth - ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-PlbAuNvR16s.html [4 part series]
@prathameshshende4
@prathameshshende4 9 месяцев назад
@@MilanJovanovicTech hope you will add some videos about sso login with openid like identity server 4 but not using identity server.
@InshuMussu
@InshuMussu 9 месяцев назад
Love your all videos.. ❤
@MilanJovanovicTech
@MilanJovanovicTech 9 месяцев назад
Thank you so much 😀
@porcinetdu6944
@porcinetdu6944 9 месяцев назад
The video is really great
@MilanJovanovicTech
@MilanJovanovicTech 9 месяцев назад
Glad you enjoyed it, I love sharing practical tips
@drhdev
@drhdev 9 месяцев назад
Can you go over deep diving logs with Azure Application Insights/Azure Log Analytics/Azure Monitor as well as exporting logs?
@MilanJovanovicTech
@MilanJovanovicTech 9 месяцев назад
Will do
@araneoadrian
@araneoadrian 9 месяцев назад
Great! Thanks!
@MilanJovanovicTech
@MilanJovanovicTech 9 месяцев назад
You bet!
@VintunaSayami
@VintunaSayami 9 месяцев назад
Log volume continues to grow over time. Seq can handle the substantial log data?? Are there specific considerations or best practices that need to be taken into account when implementing Seq?
@MilanJovanovicTech
@MilanJovanovicTech 9 месяцев назад
Seq can handle it. But you can also configure log lifetime to X days, for example.
@MilanJovanovicTech
@MilanJovanovicTech 2 месяца назад
You'd typically delete the log data after some retention period. Or you can move it into some cold storage.
@vadimr5847
@vadimr5847 9 месяцев назад
Great content as always. Thank you!
@MilanJovanovicTech
@MilanJovanovicTech 9 месяцев назад
Most welcome :)
@MuhammadYasir-cx5ng
@MuhammadYasir-cx5ng 9 месяцев назад
Can you please make a video on Grafana and make some comparison with Seg...
@MilanJovanovicTech
@MilanJovanovicTech 9 месяцев назад
Good suggestion
@PelFox
@PelFox 9 месяцев назад
Would you still recommend using Serilog of you only use application insights?
@MilanJovanovicTech
@MilanJovanovicTech 9 месяцев назад
You can still use Serilog + App Insights sink? I did that setup on one project Or just use App Insights on its own
@z070z
@z070z 6 месяцев назад
Dear Milan, Thanks a lot for your comprehensive videos. Is SEQ recommended for production or maybe using ELK stack? Can I integrate health check with SEQ ? Thank you!
@MilanJovanovicTech
@MilanJovanovicTech 6 месяцев назад
SEQ is fine for production use
@mahmoudalaskalany
@mahmoudalaskalany 9 месяцев назад
that is great video , can i use the same structuring of LogContext in azure application insights and make the search easy like this , because am suffering when searching and logging to application insights and it cost a lot of RUs
@MilanJovanovicTech
@MilanJovanovicTech 9 месяцев назад
Yes, you can. Although App Insights should already support structured logging.
@alukardishe
@alukardishe 9 месяцев назад
awsome dude
@MilanJovanovicTech
@MilanJovanovicTech 9 месяцев назад
Sure thing, love to share practical stuff 😁
@omarmet9584
@omarmet9584 Месяц назад
Great video i'm currently looking to implement logging in a project with the same structure as the project in this video with the result pattern. so far it would be good but how would i deal with unexpected exception i have the expected part handled with the result pattern like calling the saveChangesAsync, i wrapped it inside a result "still not sure if it is a good idea", but for the unexpected part i'm thinking i would have a try and catch wrapping the request in the middle but i don't think it's a good idea to have logging separated into two places. i would love to hear what do you think of this situation
@MilanJovanovicTech
@MilanJovanovicTech Месяц назад
You can create a global exception handling middleware for unhandled exceptions. You can log the error there, and return some response to the user.
@omarmet9584
@omarmet9584 Месяц назад
i am going to look into it and thanks for the fast response and your videos helped me a lot
@LeotrimJusufi
@LeotrimJusufi 9 месяцев назад
Hello Milan! Great video! Posted a comment on one of your previous videos. Pasting it here as well: “An off topic question regardin DDD and Ef Core tracking. In a classic repository pattern approach you for instance have a update method which you call upon. But is that necessary in DDD? For instance lets say i have a BasketEntity with a list of ProductEntities. If I add a product to the basket I simply call the entity method "AddProductToBasket" and just call "SaveChangesAsync" method from unit of work in the handler, and create the new line in the Db. Is this a valid approach? Because in that case - u never have to include/use the update method since Ef Core tracks the changes.” Thanks in advance!
@MilanJovanovicTech
@MilanJovanovicTech 9 месяцев назад
You don't. If you want to be purist you can use the Update method on a repo. In some cases, you'll simply need to have it to make it work with EF. As always, be pragmatic and do what works for you.
@리오날정
@리오날정 9 месяцев назад
Great Thanks~~👍
@MilanJovanovicTech
@MilanJovanovicTech 9 месяцев назад
Welcome!
@aygtx8869
@aygtx8869 9 месяцев назад
Thanks for the video, Milan, can I use Serilog throughout all the 4 Clean Architecture layers without violating its principles and without having to install the package again?
@MilanJovanovicTech
@MilanJovanovicTech 9 месяцев назад
You will very rarely need logging in Domain layer, but I don't see using ILogger a big issue
@adnenbenawicha5082
@adnenbenawicha5082 5 месяцев назад
is it possible to use serilog with MultiTenancy, because i want to log to diffrent database depending the scope of the request ?
@MilanJovanovicTech
@MilanJovanovicTech 5 месяцев назад
Not sure, sounds like an interesting problem
@InshuMussu
@InshuMussu 9 месяцев назад
I have been using serilogs, mediator, middlewares etc. But i couldn't catch this idea. how did you get this.. could you plz give some tips.. thanks
@MilanJovanovicTech
@MilanJovanovicTech 9 месяцев назад
How can I help you?
@InshuMussu
@InshuMussu 9 месяцев назад
@@MilanJovanovicTech keep posting :)
@ahmedrizk106
@ahmedrizk106 9 месяцев назад
I noticed there is already a 'RequestId' property attached to the request logs which is the same property as the correlation Id. do we need the correlation id or we can just use the request Id ?
@MilanJovanovicTech
@MilanJovanovicTech 9 месяцев назад
The value is the same, yes. That's the TraceIdentifier. However, if you want to share this across services it's better to use a custom structured log property
@janjoska2549
@janjoska2549 9 месяцев назад
Do you use logger scopes? I think they are ultra-cool. using (logger.BeginScope(new {OrderNumber = order.Number})) etc
@MilanJovanovicTech
@MilanJovanovicTech 9 месяцев назад
Scopes are the same idea as the LogContext I used in this video
@theprantadutta
@theprantadutta 9 месяцев назад
Can I use only one seq docker instance with multiple Dotnet Api projects?
@MilanJovanovicTech
@MilanJovanovicTech 9 месяцев назад
Yes (but include a Trace to know which service its from)
@theprantadutta
@theprantadutta 9 месяцев назад
@@MilanJovanovicTech Ok, thanks
@alekseygrachev4025
@alekseygrachev4025 9 месяцев назад
Thanks! What is the best way to configure log settings in an Azure function? There's no appsettings by default.
@MilanJovanovicTech
@MilanJovanovicTech 9 месяцев назад
But there is a similar settings JSON file, from what I can recall 🤔 Either way, you just want to set ENV vars
@bloopers2967
@bloopers2967 Месяц назад
Is there something like enrichers in Microsoft.Extensions.logging framework?
@MilanJovanovicTech
@MilanJovanovicTech Месяц назад
There's Scopes. You could create a scope from a middleware or MediatR pipeline and it would apply for all logs within: learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.logging.loggerextensions.beginscope?view=net-8.0
@juraj4326
@juraj4326 9 месяцев назад
Hello! And what about distributed logs ? From where context.TraceIdentifier is coming from and how to pass this value to other requests (if i'm accessing some API with HttpClient). I mean whether it is still necessary to use CorrelationId in http headers. And can u maybe explain difference beween TraceId from serilog, context.TraceIdentifier and RequestId from Serilog ?
@MilanJovanovicTech
@MilanJovanovicTech 9 месяцев назад
You can get the CorrelationId from a header
@TheAzerue
@TheAzerue 9 месяцев назад
If we use Warning for production, and later in time we need to see logs with Level "Information". Won't those logs be lost since SeriLog was skipping info logs in production ?
@MilanJovanovicTech
@MilanJovanovicTech 9 месяцев назад
They'll be lost, yes
@TheAzerue
@TheAzerue 9 месяцев назад
@@MilanJovanovicTech So isn't it safe to use level as "Information" in production as well instead of "Warning", in case we want to find or track a scenario.
@hbenvenutti
@hbenvenutti 8 месяцев назад
What was the Result object in the pipeline behavior?
@MilanJovanovicTech
@MilanJovanovicTech 8 месяцев назад
gist.github.com/m-jovanovic/aa25b1ae424c985ff8ae696a79b6fe6e
@MichalPaukert
@MichalPaukert 9 месяцев назад
There is already nuget package for correlation id. Should I use this insead?
@Kasiux
@Kasiux 9 месяцев назад
If it has a lot of stars on github, yes
@MilanJovanovicTech
@MilanJovanovicTech 9 месяцев назад
This one? github.com/stevejgordon/CorrelationId
@YasSin
@YasSin 9 месяцев назад
Great. I have the same color sweatshirt wich you can see in my profile picture as well 😂
@MilanJovanovicTech
@MilanJovanovicTech 9 месяцев назад
Nice sweatshirt we have 🔥😁
@VHMate
@VHMate 9 месяцев назад
Pls add git repo, because it's unfollowable... :(
@MilanJovanovicTech
@MilanJovanovicTech 9 месяцев назад
I share the source code in Patreon 😅
@SalmanShafiq-y3q
@SalmanShafiq-y3q 8 месяцев назад
Without water it 's crystal clear 😊 I need your help plz. your Result pattern was a real cream. i didn't miss your any video for last year. I did the following things for strong type return but it does not generate schema in Open API. public async Task Login( ISender sender, LoginRequestCommand command) { Result? result = await sender.Send(command); return result.Match( onSucceed: () => Results.Ok(result), onFailed: result.ToProblemDetails); }
@MilanJovanovicTech
@MilanJovanovicTech 8 месяцев назад
You'll have to figure out how to make TypedResults work for that. Or decorate the endpoint with descriptions on return types.
@zohibshaikh2832
@zohibshaikh2832 7 месяцев назад
Can we get the source code of this..
@MilanJovanovicTech
@MilanJovanovicTech 7 месяцев назад
On Patreon, or here: www.milanjovanovic.tech/blog/5-serilog-best-practices-for-better-structured-logging
@EvekoShadow
@EvekoShadow 5 месяцев назад
What about application insights?
@MilanJovanovicTech
@MilanJovanovicTech 5 месяцев назад
It's great
@yurii1111
@yurii1111 9 месяцев назад
Actually, you forgot to await next in the middleware.
@MilanJovanovicTech
@MilanJovanovicTech 9 месяцев назад
Nope, don't need to await - I can just return the task. And the previous step in the middleware will await it.
@yurii1111
@yurii1111 9 месяцев назад
​@@MilanJovanovicTechyes. but using scope can call dispose immediately. Technically you have introduced a race condition here.
@dy0mber847
@dy0mber847 5 месяцев назад
​@@yurii1111why is it dangerous? What could happen here? Explain, please
@sunzhang-d9v
@sunzhang-d9v 9 месяцев назад
expect Hangfire
@MilanJovanovicTech
@MilanJovanovicTech 9 месяцев назад
Hmm?
Далее
Use These 4 Best Practices For Your .NET Project Setup
10:10
You are doing .NET logging wrong. Let's fix it
25:29
Просмотров 174 тыс.
Исповедь / Мася
2:47:10
Просмотров 190 тыс.
Random Emoji Beatbox Challenge #beatbox #tiktok
00:47
Is Hono the holy grail of web frameworks?
18:33
Просмотров 7 тыс.
Modular Monoliths: How To Build One & Lessons Learned
43:37
Swagger is Gone in .NET 9! Replace It With This.
9:34
Исповедь / Мася
2:47:10
Просмотров 190 тыс.