Skip to content

Deeper LoggingLevelSwitch support #7

@nblumhardt

Description

@nblumhardt

If the root logger's minimum level is controlled by a LoggingLevelSwitch, sinks (the Seq sink in particular) can control this level in response to network messages from a remote server.

It would be great to enable this capability when working with settings (both here and in the JSON variant).

The "declaration" of a switch would need to give it both a name and initial level; subsequent "uses" of the switch would just refer to its name.

E.g.:

<!-- declare the switch -->
<add key="serilog:level-switch:Switch1" value="Debug" />
<!-- use it to control the root logger -->
<add key="serilog:minimum-level:ControlledBy" value="Switch1" />
<add key="serilog:using:Seq" value="Serilog.Sinks.Seq" />
<add key="serilog:write-to:Seq.serverUrl" value="http://localhost:5341" />
<!-- give the sink access to the switch -->
<add key="serilog:write-to:Seq.controlLevelSwitch" value="Switch1" />

This does feel somewhat ad-hoc - opinions welcome. I've held off suggesting this for a while because the usage is quite narrow for the amount of surface area, but I seem to have a question about it every week or two now so opening up the discussion :-)

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