Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to debug the sink? #69

Open
boop5 opened this issue Feb 14, 2021 · 4 comments
Open

How to debug the sink? #69

boop5 opened this issue Feb 14, 2021 · 4 comments

Comments

@boop5
Copy link

boop5 commented Feb 14, 2021

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 
@IvanKashkov
Copy link

I've faced the same issue.

@rupppe
Copy link

rupppe commented Feb 17, 2022

For me using HostNameOrAddress instead of Host was the key.

@Ghostbird
Copy link

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
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants