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

How can I set the level of logging from a json file for this library #310

Closed
pantonis opened this issue Jun 21, 2023 · 3 comments
Closed
Labels
bug Something isn't working

Comments

@pantonis
Copy link

pantonis commented Jun 21, 2023

I m using Serilog to write to a file and also to push to Elastic (using Elastic.Serilog.Sinks 8.6.0)
How can I specify in the json file which log level to append to Elastic?

  "Using": [ "Serilog.Sinks.File", "Serilog.Sinks.Console", "Serilog.ElasticSearch" ],

does not seem to work

@pantonis pantonis added the bug Something isn't working label Jun 21, 2023
@YoussefWaelMohamedLotfy
Copy link

YoussefWaelMohamedLotfy commented Jun 22, 2023

@pantonis You should be setting the MinimumLevel property in Serilog JSON Config as follows

 "Serilog": {
        // You should add this to set the minimum log level
        "MinimumLevel": {
            "Default": "Information",
            "Override": {
                "Microsoft.AspNetCore": "Warning"
            }
        },
        "WriteTo": [
            {
                "Name": "Console"
            }
            {
                "Name": "Elasticsearch",
                "Args": {
                    "nodeUris": "http://elasticsearch:9200",
                    "indexFormat": "logs-{0:yyyy.MM}",
                    "emitEventFailure": "WriteToSelfLog",
                    "autoRegisterTemplate": true,
                    "registerTemplateFailure": "IndexAnyway",
                    "numberOfShards": 2,
                    "numberOfReplicas": 1
                }
            }
        ]
    }

@pantonis
Copy link
Author

@YoussefWaelMohamedLotfy I think the Args you specified are properties of Serilog.Sink.ElasticSearch library not of this library.

@Mpdreamz
Copy link
Member

Mpdreamz commented Aug 3, 2023

Thanks for bringing this to my attention!

Opened #328 to add the ability to give the sink its own dedicated minimum log level.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants