DataDog / serilog-sinks-datadog-logs

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

Setting appsettings.json #75

Closed zinov closed 2 years ago

zinov commented 2 years ago

How is appsettings.json configuration working with your LoggerConfiguration? how do you pass to the LoggerConfiguration constructor the DatadogLogs config that is below (copied and pasted from your documentation)

"Serilog": { "Using": [ "Serilog.Sinks.Console", "Serilog.Sinks.Datadog.Logs" ], "MinimumLevel": "Debug", "WriteTo": [ { "Name": "Console" }, { "Name": "DatadogLogs", "Args": { "apiKey": "", "source": "", "host": "", "tags": [":", ":"], } } ], "Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId" ], "Properties": { "Application": "Sample" } }

zinov commented 2 years ago

This can be configure with Serilog where Configuration is an IConfiguration

var builder = new ConfigurationBuilder(); builder.AddJsonFile($"appsettings.json", optional: true, reloadOnChange: true); Configuration = builder.Build();

Log.Logger = new LoggerConfiguration() .ReadFrom.Configuration(Configuration) .CreateLogger();