帖子优先:
https://blog.csdn.net/Upgrader/article/details/88323907
https://www.cnblogs.com/cgzl/p/7616906.html
看完开干
引入nuget包:
1)Serilog
2)Serilog.Sinks.File
3)AutofacSerilogIntegration
极简主义,我们不引入Serilog.Sinks.Console 和Serilog.AspNetCore ,有File就够用了,只不过日志输出的方式不同,想了解所有Sinks,请点击这里 https://github.com/serilog/serilog/wiki/Provided-Sinks
我们建的是web api项目,所以Serilog.AspNetCore不会用到
AutofacSerilogIntegration是Serilog的Autofac集成库
引入完毕