Request: pass less data into ReadFrom.Configuration
See original GitHub issueThis is the typical setup:
var configuration = getConfiguration();
var logger = new LoggerConfiguration()
.ReadFrom.Configuration(configuration);
.CreateLogger();
However that passes the entire appsettings.json
into ReadFrom.Configuration()
. Which is not a good idea - Serilog should get only that config data it needs, no more.
It would be more robust to OPTIONALLY replace this:
.ReadFrom.Configuration(configuration);
with this:
.ReadFrom.Configuration(configuration.GetSection("Serilog"));
Both forms would be allowed to ensure backwards compatibility. Serilog would then need to decide whether the json tree it gets has “Serilog” as the root node, or not, and proceed accordingly.
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Serilog cannot find the appsettings file using readfrom
I am trying to configure a serilog logger using the appsettings.json file which is located in my.net core bin base directory.
Read more >A Serilog configuration provider that reads from Microsoft. ...
By default, configuration is read from the Serilog section. After installing this package, use ReadFrom. Configuration() and pass an IConfiguration object. ...
Read more >[Fix]-Serilog ReadFrom Configuration - appsloveworld.com
Here is how I did it to read from logging.json: var builder = new ConfigurationBuilder() .AddJsonFile(path: "logging.json", optional: false, ...
Read more >How to log to Console with .NET Core and Serilog
In this article, we will see how to add Serilog, a popular logger library, to our .NET projects: we will learn how to...
Read more >What every ASP.NET Core Web API project needs - Part 1
In a series of articles, I'm going to show the implementation of an architecture that is suitable for a thin Web API project...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi and thank you for opening an issue.
I believe both overloads already exist :
Doesn’t that cover your remarks ?
Thanks
Also true. And in that case there would be duplication of such connection strings which is a recipe for trouble.
I’m glad the overload exists because it’s good enough for my use case.