serilog-sinks-graylog
serilog-sinks-graylog copied to clipboard
How to debug the sink?
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
I've faced the same issue.
For me using HostNameOrAddress instead of Host was the key.
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.
This allowed me to debug:
- Clone this repository
- In my app repository I replaced the
PackageReference
s withProjectReference
s: 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.