Skip to content
New issue

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

Allow one channel per log level #46

Open
phillijw opened this issue Feb 26, 2024 · 1 comment
Open

Allow one channel per log level #46

phillijw opened this issue Feb 26, 2024 · 1 comment

Comments

@phillijw
Copy link

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.

@TrapperHell
Copy link
Member

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"
                            }
                        ]
                    }
                }
            }
        ]
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants