Home > Back-end >  Getting HTTP 404 response when logging from asp.net core 6.0 app to local Seq server (localhost:5341
Getting HTTP 404 response when logging from asp.net core 6.0 app to local Seq server (localhost:5341

Time:04-21

Running this test on MacOS.

Getting the following error when logging to Seq http endpoint.

2022-04-17T00:46:06.4931040Z Exception while emitting periodic batch from Serilog.Sinks.Http.Private.Sinks.HttpSink: Serilog.Debugging.LoggingFailedException: Received failed result NotFound when posting events to http://localhost:5341
   at Serilog.Sinks.Http.Private.Sinks.HttpSink.EmitBatchAsync(IEnumerable`1 logEvents)
   at Serilog.Sinks.PeriodicBatching.PeriodicBatchingSink.OnTick()
2022-04-17T00:46:06.5074610Z Exception while emitting periodic batch from Serilog.Sinks.Http.Private.Sinks.HttpSink: Serilog.Debugging.LoggingFailedException: Received failed result NotFound when posting events to http://localhost:5341

Here is the asp.net core 6.0 code snippet that's attempting to log to seq URL. Seq is running locally in docker (http://localhost:5341/ url show sup the dashboard on safari)

    using var log = new LoggerConfiguration()
    .WriteTo.Http(requestUri:"http://localhost:5341")
    .CreateLogger();
    
    Serilog.Debugging.SelfLog.Enable(Console.Error);
   
    log.Information("hello from serilog");

If I try to use the follwoing seq cli command (from terminal) to log a message on the same endpoint , it works just fine. I am not sure why I am getting the http 404 when trying to do the same from c# asp.net core app.

docker run --rm --net host datalust/seqcli:latest log -m Hello2 -s http://localhost:5341

Here is the intercept from wireshark showing the http 404 response. http 404 wireshrark

Update:

  1. While the Seq server is running in docker. The asp.net core test app is running on the local macOS terminal. using command dotnet run

CodePudding user response:

Was missing this package dotnet add package Serilog.Sinks.Seq

Figured to log to Seq need to use WriteTo.Seq("http://localhost:5341") instead of WriteTo.Http(requestUri:"http://localhost:5341").

This fixed the issue.

  • Related