Skip to content

Programatically change Args CustomChannel so it can be dinamic #28

@alexvazquez

Description

@alexvazquez

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions