Closed zolrath closed 6 years ago
Hi - thanks for the suggestion! No, support for MEL would be great in a separate library, but the plan for this one is to stay Serilog-specific. Cheers!
@nblumhardt does such library exist? How should I properly use SerilogTimings with ILogger<T>
from Microsoft.Extensions.Logging
injected via DI?
Hi @dropsonic - I'm not aware of anyone having published one, but I haven't searched carefully. As things stand, you need to use Serilog's logging interfaces with this library.
https://github.com/serilog/serilog-extensions-logging might work for your use case @dropsonic @zolrath
@zolrath Did you find a solution to this?
@sveins12 What I found is this small package, says it is "This project is a port of Serilog Timings": https://github.com/eltoncezar/LoggingTimings First time I'm trying it out too, just letting you know.
@sveins12, @ivandamyanov I created a library that support for Microsoft.Extensions.Logging.ILogger couple years ago, and published to public (8 months ago). It is an adaptation of Serilog Timings.
https://github.com/ogulcanturan/Ogu.Extensions.Logging.Timings
Hi! Great library I really appreciate the ease of timing blocks of code with a simple using! I'm currently using .net core dependency injection and their ILogger interface with Serilog registered to it.
When I try to use the
_logger.TimeOperation("Processing {recordId}", id)
syntax I am greeted with:Cannot convert instance argument type 'Microsoft.Extensions.Logging.ILogger' to 'Serilog.ILogger'
orCannot convert instance argument type 'Microsoft.Extensions.Logging.ILogger<MyClassContext>' to 'Serilog.ILogger'
I am using the
Operation.Time
method at the moment but this loses the SourceContext that has been set up on my logger during injection.Any chance the extension methods could be enhanced to support the Microsoft ILogger?
Operation
and theCompletionBehavior
enum are internal so I cannot simply drop a new extension method in my project.Thanks!