Reputation: 51
I have issue with posting logs from C# Console App to Seq. I am using NuGet package Serilog.Sinks.Seq for logging. In the console output I get error message:
Exception while emitting periodic batch from Serilog.Sinks.Seq.SeqSink: Serilog.Debugging.LoggingFailedException: Received failed result Forbidden when posting events to Seq
Seq is configured to accept all logs so it's not clear to me why logging to Seq is forbidden.
Source code of the console app:
using Serilog;
using System;
namespace SeqLogTest
{
class Program
{
static void Main(string[] args)
{
Log.Logger = new LoggerConfiguration().WriteTo.Seq("http://localhost:5341").CreateLogger();
Serilog.Debugging.SelfLog.Enable(Console.Error);
Log.Warning("Hello Seq, it is warning!");
Log.CloseAndFlush();
Console.ReadKey();
}
}
}
Thanks for any help!
Upvotes: 2
Views: 2930
Reputation: 3089
Have been witnessing a very peculiar problem with seq
on windows that was not ingesting any logs, similar to what @dima-bondarenko was reporting.
The error message was slightly different Failed with status code ServiceUnavailable (Service Unavailable)
Nevertheless I'll leave some troubleshooting ideas in here as well, maybe one day someone might benefit from it :)
In our case, serilog
was running along with a .net 5 api having seq
as yet another sink.
The setup was working just fine out of the box, without any particular configuration on quite a few dev machines except one.
Logs ingestion simply did not work and nothing ended up being logged in seq.
Things to look after
Serilog.Debugging.SelfLog.Enable(Console.Error);
Failed with status code ServiceUnavailable (Service Unavailable)
seqcli log -m Hello
Failed with status code ServiceUnavailable (Service Unavailable)
curl http://localhost:5341
sounded like the corporate proxy was interfering, though the
don't use the proxy for local addresses
proxy system setting was enabled
<p>Generated Mon, 19 Apr 2021 12:27:26 GMT by proxy.some.domain.com</p>
<!-- ERR_CONNECT_FAIL -->
printenv HTTP_PROXY
bingo, some docker leftovers might have altered the http proxy setting.
removing the environment variable made theseqcli
push happy again.
seqcli log -m "Hello again"
but the application was still witnessing
Service Unavailable
though
5341
as there was one rule similar to the bellow snippetnetsh advfirewall firewall add rule name="Seq Open Port 5341" dir=in action=allow protocol=TCP localport=5341
at first sight, removing the firewall inbound rule did not seem to have fixed the
Service Unavailable
though
and guess what, everything is back to normal again
At the end of the day seq
is a fantastic product and generally speaking it just works :)
but sometimes the combination of some misconfiguration factors could easily ruin the day :)
Upvotes: 1
Reputation: 51
So it turned out that the reason of the problem was incorrectly created Windows firewall rule which was supposed to allow connections on port 5341 but it wasn't working actually. After having deleted the rule, Seq started showing logs just fine.
Upvotes: 2