Setting up Logging (w/ .NET Host, Serilog, and File Logging) - EASY WPF (.NET 5)

preview_player
Показать описание
Learn how to setup logging in a WPF application. In WPF, the best destination to write logs is to a file. However, Microsoft does not provide a mechanism to write logs to a file. That said, I also demonstrate how to leverage third-party logging providers, in this case Serilog, to write logs to a file. I go over a few useful configuration options for logging, but this tutorial focuses on setting up the logging rather than all the amazing and advanced configuration options.

TIMESTAMPS:
0:00 - Introduction
1:04 - Demo Introduction
1:48 - Microsoft.Extensions.Logging Setup
3:47 - Configuring Microsoft.Extensions.Logging
5:42 - Microsoft.Extensions.Logging w/ Host
7:15 - Issues w/ Microsoft.Extensions.Logging
8:10 - Serilog Setup
10:01 - Logging to a File w/ Serilog
12:25 - Serilog w/ Host
13:52 - Conclusion

OTHER LINKS:
Рекомендации по теме
Комментарии
Автор

Great job, man. I'm old now and I hate having to figure all this crap out again with framework changes. You're clear and concise. I love it.

jonnyjazzz
Автор

I have leaned all of your demoes, they are very useful for me, Thank you very much. I am 67 years old, and used C# more than 10 years, but not very familiar with WPF, I think your tutorials are the best in Youtube WPF videos. I found you are updating your tutorials recently. I hope you can create a link to your playlist in every tutorial demo.

ZergCool
Автор

Thanks for this, SingletonSean. This is one of the more opaque areas of WPF yet it's so important.

vincentotieno
Автор

One of the best explanations I've seen for setting up Serilog! THANK YOU! And I needed it for logging to a file in a console application, not WPF, but just as applicable there.

Tolg
Автор

Impressive, everything but using appsettings was covered, great job.

rmsoft
Автор

Thank you Sean! Every time I need to do something in WPF you were there months ago.

markmahowald
Автор

Very interesting video, Sean! :D An important aspect, especially when your application is growing.

joachimally
Автор

Great information thank you, such an important part of any application. I would be grateful if you have any concepts for best practices for monitor these log messages within a WPF application while its operating? Keep up the great work! Thanks

GeoffWilby
Автор

This is really another good video, with your dependency series, I learned lot and helped me lot, your chart is also very easy to implement. I've one question here, can split the logger files for error log and log information?

ayan-qnor
Автор

Great video.
When do you dispose the logger? Can you use DI so that I don’t need to add ILogger<ClassName> to host for every class I want to log? Thank you!

Sygmond
Автор

I don't know if I understand this correctly, but can you only log your own custom messages? Is there no way to log, let's say, the messages from the output console?

djelasrca
Автор

Hi Sean. Thank you for this great content.
Using the HostBuilder, How Do I enable the user to change the log level?

abd.alharbi
Автор

Hi Sean, thanks for the tutorial. I have a question: In other tutorials, you're instantiating the commands within the ViewModels. Should I inject all the loggers for these commands into the ViewModels and then pass it to the commands, or do you prefer another solution for this case? Thanks in advance for your answer!

leonardgberl
Автор

Hi, how do I setup this if my WPF application isn't using MVC model?

MrVicho
Автор

Hello there. I have simple question. Sine you are doing great WPF content, would you consider do some of ReactiveUI? Maybe even full stack like you did back a while? You cleared almost all of my MVVM questions and issues. There is no usefull ReactiveUI stack to watch, so it could be also opportunity. Thanks for reading and keep it up

Tof__