serilog-settings-appsettings icon indicating copy to clipboard operation
serilog-settings-appsettings copied to clipboard

.ReadFrom.AppSettings(prefix) silently ignores missing settings

Open Xerillio opened this issue 7 months ago • 1 comments

When using the AppSettings(prefix) overload, Serilog neither fails nor complains in the SelfLog about not finding any appSettings with that prefix.

How to reproduce

Create a project with no serilog related settings in web.config/app.config.

Setup SelfLog:

Serilog.Debugging.SelfLog.Enable(Console.Error); // Or some other destination of choice

Create a logger with any prefix:

var logger = new LoggerConfiguration()
    .ReadFrom.AppSettings("MyLoggerA")
    .CreateLogger();

logger.Information("Some log message");

Notice there's nothing written to Console.Error.

I can't figure out if that's by design or not, but it seems unintuitive, that this should silently go through without at least a warning in SelfLog.


If I instead add settings like:

<add key="MyLoggerA:serilog:using:File" value="Serilog.Sinks.File" />
<add key="MyLoggerA:serilog:write-to:File.path" value="Q:\Logs\Foged\Server\ApplicationLog.txt" />

It complains in SelfLog as I don't have a Q: drive.

Xerillio avatar Aug 02 '24 09:08 Xerillio