The basic use of Serilog
(I. Introduction
(B) introducing the package
(C) Configuration
- Direct configuration
- Profile Configuration
(D) Use
(E) Conclusion
I. Introduction
As a white, to review the use serilog, if wrong place, please bigwigs treatise.
Here are some information:
Official Website: https://serilog.net/
Github:https://github.com/serilog/serilog
Comparison with other log components: https://stackify.com/nlog-vs-log4net-vs-serilog/ (I seriously doubt article was written by author serilog)
Introducing two packets
Conventional .net core mvc template, for example, by nuget need to import about several packages.
Serilog: Serilog core package
Serilog.AspNetCore: to provide a method for the aspnetcore
Serilog.Settings Configuration:. Provide serilog read the configuration file method
Serilog.Sinks.xxx: to provide various output methods (such as the output to the console, file, database)
Three configuration
Asp.net core framework components have default log, you need the original cover (it should be so understanding it -.-).
1 direct configuration
Program.cs modified:
If you need more configuration you can view the official documentation.
2 Profile Configuration
The first to write appsetting.json:
Configuration according to their needs, because to do the test on the first write.
Program.cs modified:
So far serilog been configured, in general, relatively simple configuration.
IV use
By using dependency injection to
Five Conclusion
The first to write blog content relatively empty. . . Behind will continue to record learning content, if there is an error in the text found Gangster, please leave a message to tell me, very grateful.