Skip to content

Specifying the Serilog assembly is needed when passing the name of an interface implementation #81

@tsimbalar

Description

@tsimbalar

When a sink/enrichment/filtering method accepts a parameter which is an interface, the different settings providers accept as a value "the qualified name of an implementation".

For instance, to specify an implementation of Serilog.Formatting.ITextFormatter such as Serilog.Formatting.Json.JsonFormatter, the following value can be passed : "Serilog.Formatting.Json.JsonFormatter, Serilog" , for instance :

{
  "Serilog": {
    "Using": [ "TestDummies" ],
    "WriteTo": [
      {
        "Name": "DummyWithFormatter",
        "Args": {
          "formatter": "Serilog.Formatting.Json.JsonFormatter, Serilog"
        }
      }
    ]
  }
}

It turns out that the AppSettings provider does not require the assembly name for methods coming from the Serilog assembly, and this can be used :

  <appSettings>
    <add key="serilog:using:TestDummies" value="TestDummies" />
    <add key="serilog:write-to:DummyWithFormatter.formatter" value="Serilog.Formatting.Json.JsonFormatter" />
  </appSettings>

For consistency it would be nice if Serilog.Settings.Configuration behaved the same and did not require to specify the assembly name Serilog for types that come from that assembly.

(I have found this edge case whil working on serilog/serilog#1053 and have a failing test case here :
https://github.com/tsimbalar/serilog-settings-comparison/blob/b547207ebace1dc3e7283d1dba231132e7de0a3b/test/Serilog.Settings.Comparison.Tests/3-Advanced%20settings%20formats/331_ImplementationDefaultConstructor.cs#L21-L36
)

It looks lik serilog/serilog#1065 may be similar.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions