Closed upnxt closed 1 year ago
@ogaca-dd, @gh123man is there an ETA on when this may be reviewed?
@upnxt
Thanks for the PR. I understand your use case - but have you considered overriding the configuration before initializing the Sink? You can do this today with IConfigurationRoot
without making an api surface change to the sink.
var configuration = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile(path: "appsettings.json", optional: false, reloadOnChange: true)
.Build();
// Something like this
configuration["Serilog:WriteTo:0:Args:apiKey"] = "SOME_API_KEY";
Log.Logger = new LoggerConfiguration()
.ReadFrom.Configuration(configuration)
...
@upnxt Thanks for the PR. I understand your use case - but have you considered overriding the configuration before initializing the Sink? You can do this today with
IConfigurationRoot
without making an api surface change to the sink.var configuration = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile(path: "appsettings.json", optional: false, reloadOnChange: true) .Build(); // Something like this configuration["Serilog:WriteTo:0:Args:apiKey"] = "SOME_API_KEY"; Log.Logger = new LoggerConfiguration() .ReadFrom.Configuration(configuration) ...
Hah, times like these are a bit embarrassing when completely overlooking the most basic fix. Thanks for the reminder, I'll close this out!
Currently it appears the DataDog sink must be configured via appsettings or
.WriteTo.DatadogLogs(...)
without a way to overlap the two configuration methods. For those of us that want to configure the sink via appsettings, but do not want to source control our API key this poses a problem.This PR will merge appsetting values with the hard-coded
DatadogLogs
parameters making a combined configuration possible.