DataDog / serilog-sinks-datadog-logs

Serilog Sink that sends log events to Datadog https://www.datadoghq.com/
Apache License 2.0
62 stars 42 forks source link

Support for datadog.json? #60

Open rburnham52 opened 3 years ago

rburnham52 commented 3 years ago

The APM setup for Datadog's Asp.net core integration suggests that it should be configured using datadog.json.

{
  "DD_API_KEY": "",
  "DD_SERVICE": "MyService",
  "DD_ENV": "Prod",
  "DD_VERSION": "1.2",
  "DD_LOGS_INJECTION": true,
  "DD_TRACE_ENABLED": true,
  "DD_TRACE_ANALYTICS_ENABLED": true
}

It looks like the Serilog Sink does not read configuration values from this file. For example the Service name is not appearing in the logs recorded by datadog.

I'm using code first approach to provide the API key because we don't want to log out development environment so we leave the key blank until deployed. If you have a blank key by default it throws an exception

var ddApiKey = context.Configuration.GetValue<string>("DD_API_KEY");
if (!string.IsNullOrWhiteSpace(ddApiKey))
    loggerConfig.WriteTo.DatadogLogs(ddApiKey, logLevel:LogEventLevel.Debug);

I noticed the ConfigurationSection property but this would require a sub section of your json file like

"Datadog": {
  "DD_API_KEY": "",
  "DD_SERVICE": "MyService",
  "DD_ENV": "Prod",
  "DD_VERSION": "1.2",
  "DD_LOGS_INJECTION": true,
  "DD_TRACE_ENABLED": true,
  "DD_TRACE_ANALYTICS_ENABLED": true
}

is datadog.json config file supported?

ogaca-dd commented 3 years ago

@ryburn52,

datadog.json is not supported, but appsettings.json is supported.

rburnham52 commented 3 years ago

That's what i have had to do so far, i was hoping to have all my datadog settings in the once place though