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.
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!
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.
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.
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?
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!
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
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?
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
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!
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.
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 ?
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
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
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 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.
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 ?
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); }
Want to master Clean Architecture? Go here: bit.ly/3PupkOJ
Want to unlock Modular Monoliths? Go here: bit.ly/3SXlzSt
This is one of the best videos on your channel. No water, only good explanation and example. Keep doing like this!
Glad you liked it! Working on upping the content quality :)
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.
Hope you enjoy it!
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!
Thanks a lot, this means the world to me 😍
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.
So cool! Thanks for letting me know. 😁 I actually have a copy of the book, but I missed this.
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.
- JWT - ruclips.net/video/4cFhYUK8wnc/видео.html
- JWT + Firebase - ruclips.net/video/xBuLWaDcvu0/видео.html
- Permission auth - ruclips.net/video/PlbAuNvR16s/видео.html [4 part series]
@@MilanJovanovicTech hope you will add some videos about sso login with openid like identity server 4 but not using identity server.
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?
Seq can handle it. But you can also configure log lifetime to X days, for example.
You'd typically delete the log data after some retention period. Or you can move it into some cold storage.
Can you go over deep diving logs with Azure Application Insights/Azure Log Analytics/Azure Monitor as well as exporting logs?
Will do
Can you please make a video on Grafana and make some comparison with Seg...
Good suggestion
Love your all videos.. ❤
Thank you so much 😀
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!
SEQ is fine for production use
Would you still recommend using Serilog of you only use application insights?
You can still use Serilog + App Insights sink? I did that setup on one project
Or just use App Insights on its own
This is awesome and useful video
Glad you think so!
The video is really great
Glad you enjoyed it, I love sharing practical tips
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
Yes, you can. Although App Insights should already support structured logging.
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?
You will very rarely need logging in Domain layer, but I don't see using ILogger a big issue
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
You can create a global exception handling middleware for unhandled exceptions. You can log the error there, and return some response to the user.
i am going to look into it and thanks for the fast response and your videos helped me a lot
Great content as always. Thank you!
Most welcome :)
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!
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.
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
How can I help you?
@@MilanJovanovicTech keep posting :)
Great! Thanks!
You bet!
Can I use only one seq docker instance with multiple Dotnet Api projects?
Yes (but include a Trace to know which service its from)
@@MilanJovanovicTech Ok, thanks
Do you use logger scopes? I think they are ultra-cool. using (logger.BeginScope(new {OrderNumber = order.Number})) etc
Scopes are the same idea as the LogContext I used in this video
awsome dude
Sure thing, love to share practical stuff 😁
is it possible to use serilog with MultiTenancy, because i want to log to diffrent database depending the scope of the request ?
Not sure, sounds like an interesting problem
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 ?
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
Is there something like enrichers in Microsoft.Extensions.logging framework?
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
Thanks! What is the best way to configure log settings in an Azure function? There's no appsettings by default.
But there is a similar settings JSON file, from what I can recall 🤔
Either way, you just want to set ENV vars
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 ?
They'll be lost, yes
@@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.
What was the Result object in the pipeline behavior?
gist.github.com/m-jovanovic/aa25b1ae424c985ff8ae696a79b6fe6e
Great Thanks~~👍
Welcome!
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 ?
You can get the CorrelationId from a header
There is already nuget package for correlation id. Should I use this insead?
If it has a lot of stars on github, yes
This one? github.com/stevejgordon/CorrelationId
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);
}
You'll have to figure out how to make TypedResults work for that. Or decorate the endpoint with descriptions on return types.
Great. I have the same color sweatshirt wich you can see in my profile picture as well 😂
Nice sweatshirt we have 🔥😁
Pls add git repo, because it's unfollowable... :(
I share the source code in Patreon 😅
What about application insights?
It's great
Can we get the source code of this..
On Patreon, or here: www.milanjovanovic.tech/blog/5-serilog-best-practices-for-better-structured-logging
Actually, you forgot to await next in the middleware.
Nope, don't need to await - I can just return the task. And the previous step in the middleware will await it.
@@MilanJovanovicTechyes. but using scope can call dispose immediately. Technically you have introduced a race condition here.
@@yurii1111why is it dangerous? What could happen here? Explain, please
expect Hangfire
Hmm?