serilog-sinks-graylog icon indicating copy to clipboard operation
serilog-sinks-graylog copied to clipboard

How to debug the sink?

Open boop5 opened this issue 3 years ago • 4 comments

The sink won't send any messages to graylog. Graylog is working fine with other sources. The input is setup correctly. When I try to log with Serilog.Sinks.Graylog then wireshark won't capture any packets. So I'm kinda lost at this point. What is the way to troubleshoot the sink?

var logConfig = new LoggerConfiguration()
                .MinimumLevel.Verbose()
                .Destructure.With<SensitiveDataDestructuringPolicy>()
                .Enrich.WithCorrelationId()
                .Destructure.ToMaximumDepth(4)
                .Destructure.ToMaximumStringLength(100)
                .Destructure.ToMaximumCollectionCount(20)
                .WriteTo.Graylog(new GraylogSinkOptions
                {
                    Host = "127.0.0.1",
                    Port = 12201,
                    TransportType = TransportType.Udp // also tried TCP and HTTP
                });

When I send a message per nc it works just fine

echo -e '{"version": "1.1","host":"localhost","short_message":"Hello World","full_message":"Hello World","level":1}\0' | nc -u -w 1 127.0.0.1 12201 

boop5 avatar Feb 14 '21 00:02 boop5

I've faced the same issue.

IvanKashkov avatar Oct 15 '21 20:10 IvanKashkov

For me using HostNameOrAddress instead of Host was the key.

rupppe avatar Feb 17 '22 22:02 rupppe

Same issue for me. I've got this working beautifully on our server and various clients, but it doesn't work on our Xamarin Android app, and I can't find why.

Ghostbird avatar Jul 01 '22 15:07 Ghostbird

This allowed me to debug:

  • Clone this repository
  • In my app repository I replaced the PackageReferences with ProjectReferences: Note that the relative path may differ depending on your filesystem set-up
    <ItemGroup>
      <ProjectReference Include="../../serilog-sinks-graylog/src/Serilog.Sinks.Graylog/Serilog.Sinks.Graylog.csproj" />
      <ProjectReference Include="../../serilog-sinks-graylog/src/Serilog.Sinks.Graylog.Batching/Serilog.Sinks.Graylog.Batching.csproj" />
      <ProjectReference Include="../../serilog-sinks-graylog/src/Serilog.Sinks.Graylog.Core/Serilog.Sinks.Graylog.Core.csproj" />
    </ItemGroup>
    

Additionally I found it very useful to enable Serilog's own debugging mechanism by adding this line to the startup file.

Serilog.Debugging.SelfLog.Enable(msg => Console.WriteLine(msg));

This ensures that errors that occur inside the Graylog sink are written to the Console. This works regardless of the set-up above.

Ghostbird avatar Jul 08 '22 09:07 Ghostbird