'Serilog with Graylog not logging

I have a Web API and I'm trying to log messages into Graylog, using Serilog. Now matter what I do, no messages are shown in my Graylog application. This is what I have so far:

This is in my Program.cs

var logger = new LoggerConfiguration().
    ReadFrom.Configuration(builder.Configuration).
    Enrich.FromLogContext().
    CreateLogger();

builder.Logging.ClearProviders();
builder.Logging.AddSerilog(logger);

This is my configuration:


  "Serilog": {
    "Using": [ "Serilog.Sinks.Graylog" ],
    "MinimumLevel": "Information",
    "WriteTo": [
      {
        "Name": "Graylog",
        "Args": {
          "hostnameOrAddress": "127.0.0.1",
          "port": "12201",
          "transportType": "Udp"
        }
      }
    ],
    "Properties": {
      "Application": "Centralized logging application"
    }
  },
  "AllowedHosts": "*"
}

And I'm trying to log a:

_logger.LogError(0, new Exception("Exception Message"), "Message", new WeatherForecast());

Can someone please help me? I need to see my exception inside Graylog.

Thanx a lot in advance



Solution 1:[1]

Do you have the input set up on the Graylog side? Have you verified that you can get messages to that input?

Finally, I noticed you were sending it to local host. Are both applications on the same machine? If not, you will want to put in the address of the Graylog server.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Blackbox