skip to Main Content

I have .NET 5 web app which is supposed to write logs to DataDog using Serilog Sink (Serilog.Sinks.Datadog.Logs v0.5.2). Here is my Program.cs:

static async Task Main(string[] args)
{
    using (var log = new LoggerConfiguration()
        .MinimumLevel.Verbose()
        .WriteTo.DatadogLogs("HERE IS MY API KEY", service: "myservice", configuration: new DatadogConfiguration() { Url = "https://http-intake.logs.us3.datadoghq.com" })
        .CreateLogger())
    {
        log.Debug("debug");
        log.Information("information");
        log.Verbose("verbose");
        log.Warning("warning");
        log.Error("error");
        log.Fatal("fatal");
    }

    using IHost host = CreateHostBuilder(args).Build();

    await host.RunAsync();
}

After running the app i can see all these logs in DataDog EXCEPT Information logs. So, i see only 5 messages instead of 6. What i’m doing wrong?

2

Answers


  1. Chosen as BEST ANSWER

    The reason turned out to be on DataDog side. There was an indexation rule set up in our Logs Configuration that is telling to exclude 99% of all INFO logs (DataDog > Logs > Configuration > Indexes tab). Disabling this rule solved the issue.


  2. I think the issue is that you’re setting the Serilog log event level but not the Datadog level. Try this:

    .WriteTo.DatadogLogs("HERE IS MY API KEY", 
            service: "myservice",
            logLevel: LogEventLevel.Information,
            configuration: new DatadogConfiguration() { 
                Url = "https://http-intake.logs.us3.datadoghq.com" }
        )
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search