Open phillijw opened 9 months ago
I disagree that this is something that this library should handle, considering that there are libraries specialized for expression-based filtering. One such library is Serilog Expressions.
Assuming that you are loading the Serilog configuration from a JSON file, you could use something akin to this (switching from Console
logging to Slack
):
{
"Serilog": {
"Using": [ "Serilog.Expressions", "Serilog.Sinks.Console" ],
"WriteTo": [
{
"Name": "Logger",
"Args": {
"configureLogger": {
"Filter": [
{
"Name": "ByIncludingOnly",
"Args": {
"expression": "(@l = 'Information')"
}
}
],
"WriteTo": [
{
"Name": "Console"
}
]
}
}
},
{
"Name": "Logger",
"Args": {
"configureLogger": {
"Filter": [
{
"Name": "ByIncludingOnly",
"Args": {
"expression": "(@l = 'Warning')"
}
}
],
"WriteTo": [
{
"Name": "Console"
}
]
}
}
}
]
}
}
It would be good if each log level (info, debug, trace, warning, error, critical, etc) could have their own channel specified to send messages to.