This should be simple, but I cannot find an answer.
I have an ASP.NET Core (3.0) application. I use Microsoft.Extensions.Logging/ILogger
for logging.
I am also using a library (Fishbus: github/nuget) for interfacing with Azure Message Bus. The library logs suitable messages, but uses Serilog to do it. So out of the box, no messages are logged.
How do I "connect" Serilog to the Microsoft logging framework so that I can see what the library is doing?
You can't, per se. You are beholden to what the library uses. Microsoft.Extensions.Logging
is a facade, so when you depend on that, the application can sub in an actual logging provider. However, when the library depends on the provider itself (i.e. Serilog), then there's no way to hook it into Microsoft.Extensions.Logging
or another provider.
That said, the same Serilog config can be used for both, if you also use the Serilog provider for Microsoft.Extensions.Logging
. They wouldn't be generating the logs in the same way, but they'd all end up in the same sink(s). Additionally, Serilog is somewhat of a facade itself, with its concept of sinks, so while you ultimately can't get rid of Serilog, you can configure different logging destinations via Serilog, instead of using different Microsoft.Extensions.Logging
providers.