Closed eleazarcelis closed 3 weeks ago
i want to take the bug and work on it
Hi! This doesn't look like a Serilog bug - it's probably better to post this one to Stack Overflow and work through all of the details around your setup. At first glance it looks like your JSON config is invalid - "Serillog" should be a root element and not under "Logging". HTH!
{ "Logging": { "LogLevel": { "Default": "Information", "Microsoft.AspNetCore": "Warning" }, "Serilog": { "Using": [ "Serilog.Sinks.Console", "Serilog.Sinks.File" ], "MinimumLevel": "Debug", "Override": { "Microsoft.AspNetCore": "Warning", "Microsoft": "Warning", "System": "Warning" }, "Enrich": [ "FromLogContext" ], "WriteTo": [ { "Name": "Console", "Args": { "formatter": { //
type(or $type) is optional, must be specified for abstract declared parameter types "type": "Serilog.Templates.ExpressionTemplate, Serilog.Expressions", "template": "[{@t:HH:mm:ss} {@l:u3} ---- {Coalesce(SourceContext, '<none>')}] {@m}\n{@x}" } } }, { "Name": "File", "Args": { "path": "\\logs\\log.txt" } } ] } }
Thanks! Maybe you should consider explicitly including this information on https://github.com/serilog/serilog-settings-configuration for clueless folks.
Maybe you should consider explicitly including this information on https://github.com/serilog/serilog-settings-configuration for clueless folks.
If you could make a PR that contains an example that would have helped you, that'd be a really great help for all concerned.
"The obvious thing to show" is never as obvious when you wrote it and/or have used it lots of times and it just worked (either because somebody else rigged it or you copied from something that had it correct).
Maybe you should consider explicitly including this information on https://github.com/serilog/serilog-settings-configuration for clueless folks.
If you could make a PR that contains an example that would have helped you, that'd be a really great help for all concerned.
"The obvious thing to show" is never as obvious when you wrote it and/or have used it lots of times and it just worked (either because somebody else rigged it or you copied from something that had it correct).
I have generated PR #416 I hope this will help.
Thank you! (I personally have never used the package, so someone more familiar with it will be along to review and/or merge it in due course)
Thanks for your contribution @eleazarcelis.
Description ReadFrom.Configuration is not able to use configuration parameters from the appsettings.json file. It does not write the expected format on the console, it does not generate the expected log file.
this is my appsettings.json:
the appsettings class:
the main:
Reproduction add nuget package: dotnet add package Serilog (3.1.1) dotnet add package Serilog.AspNetCore (8.0.1) dotnet add package Serilog.Sinks.Console (5.0.1) dotnet add package Serilog.Sinks.File (5.0.0)
Expected behavior See the expected format on the console and the file in the expected folder
Relevant package, tooling and runtime versions N/A
Additional context Framework: Net Core 8
Project type: API