serilog / serilog-settings-configuration

A Serilog configuration provider that reads from Microsoft.Extensions.Configuration
Apache License 2.0
446 stars 129 forks source link

How to dynamically disable a specific Sink from configuration? #370

Open pedoc opened 1 year ago

pedoc commented 1 year ago

An minimal example configuration is as follows:

{
    "Serilog": {
        "WriteTo": [
            {
                "Name": "Async",
                "Args": {
                    "BufferSize": 512,
                    "Configure": [
                        {
                            "Name": "Console",
                            "Args": {
                                "outputTemplate": "[{Timestamp:HH:mm:ss.fff} {Level:u3}] {Message:lj} <s:{SourceContext}>{NewLine}{Exception}"
                            }
                        },
                        {
                            "Name": "Debug",
                            "Args": {
                                "outputTemplate": "[{Timestamp:HH:mm:ss.fff} {Level:u3}] {Message:lj} <s:{SourceContext}>{NewLine}{Exception}"
                            }
                        }
                    ]
                }
            }
        ]
    }
}

I want to disable Console Sink when Environment.UserInteractive=false,How should it be configured?

thanks