We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I have two Slack Sinks that log to different Channels.
One Channel is for logs and the other is for alerts. Like below:
.WriteTo.Slack( webhookUrl: "https://hooks.slack.com/services/hook1", //hook for alerting CST customChannel: "aletr", customUsername: $"alert-bot", customIcon: ":radioactive_sign:", restrictedToMinimumLevel: LogEventLevel.Fatal ) .WriteTo.Slack( webhookUrl: "https://hooks.slack.com/services/hook2", customChannel: "logs", customUsername: $"log-bot", customIcon: ":radioactive_sign:", restrictedToMinimumLevel: LogEventLevel.Error );
Currently I am managing this by making the alert Channels log level as Fatal. But I wan to log Certain Errors as Alerts.
But I cant do that directly as then I will have decrease the logLevel for Alert Channel and it will be polluted by all the Error Logs
The text was updated successfully, but these errors were encountered:
I am of the opinion that this is not the right way to achieve what you're looking for, and is beyond the scope and intents of this sink.
I believe that Serilog.Expressions might be what you're looking for in order to accomplish this.
Amongst other ways, I think you could use the EventId as a selector. Consider the following configuration:
"WriteTo": [ { "Name": "Logger", "Args": { "configureLogger": { "Filter": [ { "Name": "ByIncludingOnly", "Args": { "expression": "EventId.Id = 1" } }], "WriteTo": [ { "Name": "Slack", "Args": { "webHookUrl": "..." } }] } } }, { "Name": "Logger", "Args": { "configureLogger": { "Filter": [ { "Name": "ByIncludingOnly", "Args": { "expression": "EventId.Id = 2" } }], "WriteTo": [ { "Name": "Slack", "Args": { "webHookUrl": "..." } }] } } }]
It's a bit bulky and repetitive but it does get the job done. As for usage, it goes something like this:
logger.LogWarning(1, "...");
Sorry, something went wrong.
TrapperHell
No branches or pull requests
I have two Slack Sinks that log to different Channels.
One Channel is for logs and the other is for alerts. Like below:
.WriteTo.Slack(
webhookUrl: "https://hooks.slack.com/services/hook1",
//hook for alerting CST
customChannel: "aletr",
customUsername: $"alert-bot",
customIcon: ":radioactive_sign:",
restrictedToMinimumLevel: LogEventLevel.Fatal
)
.WriteTo.Slack(
webhookUrl: "https://hooks.slack.com/services/hook2",
customChannel: "logs",
customUsername: $"log-bot",
customIcon: ":radioactive_sign:",
restrictedToMinimumLevel: LogEventLevel.Error
);
Currently I am managing this by making the alert Channels log level as Fatal. But I wan to log Certain Errors as Alerts.
But I cant do that directly as then I will have decrease the logLevel for Alert Channel and it will be polluted by all the Error Logs
The text was updated successfully, but these errors were encountered: