what is difference between Serilog.Sinks.File and Serilog.Extensions.Logging.File packages in asp.net core?
When I tried to implement logging in asp.net core project with Serilog I found a quick example here which used Serilog.Sinks.File.
When I tried to implement the same in my project,the logger factory didnt have the extension AddFile().
But when I added another extension Serilog.Extensions.Logging.File I got the extension.
Are both extensions needed? or just Logging.File extension is enough?
What is the basic difference Sinks.File and Logging.File ?
In the link you provided, the example explicitly use Serilog.Extensions.Logging.File.
It is this extension that provide the AddFile method to ILoggerFactory (via Extension Methods mecanisms in DotNet) :
Extension of Microsoft.Extensions.Logging.IloggerFactory
A quick look at the Nuget package definition of Serilog.Extensions.Logging.File indicates that it has a dependency on
Serilog.Sinks.RollingFile.
The latter extension itself has a dependency on Serilog.Sinks.File.
So, Serilog.Extensions.Logging.File extends ILoggerFactory, providing the AddFile() method. That method uses the RollingFile class (as seen in the source code).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With