serilog-sinks-slackclient icon indicating copy to clipboard operation
serilog-sinks-slackclient copied to clipboard

Programatically change Args CustomChannel so it can be dinamic

Open alexvazquez opened this issue 2 years ago • 0 comments

I have Serilog slack configuration in appsettings.json:

{ "Name": "Slack", "Args": { "WebHookUrl": "https://hooks.slack.com/services/xxxx/xxxxx/xxxxxxx", "CustomChannel": "#dev-log", "CustomUserName ": "Slack Logger", "BatchSizeLimit": 20, "QueueLimit": 1000, "CustomIcon": ":ghost:", "TimestampFormat": "o", //"MinimumLogEventLevel": "Warning" "restrictedToMinimumLevel": "Warning" } }

I need to change in runtime the CustomChannel because in my code depending of logic I should notify to different channels.


` 
LogContext.PushProperty("Environment", environment.ToString());
                        LogContext.PushProperty("UserName", loggedUserName);
                        LogContext.PushProperty("ErrorUID", logException.ErrorUid.ToString());
                        LogContext.PushProperty("SecuritySessionID", sessionUid);

                        // *** HERE I NEED TO SET THE CustomChannel PROPERTY *** //

                        _logger.LogError(exception, $"An error with ID {errorUid} ocurred.");`

Any clue?

alexvazquez avatar Nov 21 '22 03:11 alexvazquez