- Notifications
You must be signed in to change notification settings - Fork 73
Closed
Description
Requirement - what kind of business use case are you trying to solve?
I need to send to Jaeger custom logs. Now it works only when I use Microsoft.Extensions.Logging.ILoggerFactory
My Startup
public void ConfigureServices(IServiceCollection services) { services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); services.AddOpenTracing(); services.AddSingleton<ITracer>(sp => { var loggerFactory = sp.GetRequiredService<ILoggerFactory>(); var reporter = new RemoteReporter.Builder() .WithSender(new UdpSender()) .WithLoggerFactory(loggerFactory) .Build(); var tracer = new Tracer .Builder("Sample service") .WithReporter(reporter) .WithSampler(new ConstSampler(true)) .Build(); GlobalTracer.Register(tracer); return tracer; }); }
Somewhere in controller:
using Microsoft.Extensions.Logging;
namespace WebApplication2.Controllers { [Route("api/[controller]")] public class ValuesController : ControllerBase { private readonly ILogger<ValuesController> _logger; public ValuesController(ILogger<ValuesController> logger) { _logger = logger; } // GET api/values/5 [HttpGet("{id}")] public ActionResult<string> Get(int id) { _logger.LogWarning("Get values by id: {valueId}", id); return "value"; }
Problem - what in Jaeger blocks you from solving the requirement?
But when I use Serilog, there are no any custom logs. I just install serilog and add
public static IWebHostBuilder CreateWebHostBuilder(string[] args) { return WebHost.CreateDefaultBuilder(args) .UseStartup<Startup>() .UseSerilog(); }
Could you please suggest why custom logging doesn't work with Serilog?
Metadata
Metadata
Assignees
Labels
No labels