Ask Your Question
0

How can I turn off HTTP request tracking in Serilog's appsettings.json?

asked 2023-06-20 21:34:48 +0000

bukephalos gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2023-06-20 21:51:02 +0000

scrum gravatar image

To turn off HTTP request tracking in Serilog's appsettings.json, you need to update the configuration of the Serilog.AspNetCore package in the appsettings.json file. You can do this by adding the following line to the "Serilog" section of the appsettings.json file:

"Serilog": {
    "MinimumLevel": {
        "Default": "Information",
        "Override": {
            "Microsoft": "Warning",
            "System": "Warning"
        }
    },
    "WriteTo": [
        {
            "Name": "Console"
        },
        {
            "Name": "File",
            "Args": {
                "path": "logs/log.json",
                "formatter": "Serilog.Formatting.Json.JsonFormatter, Serilog"
            }
        }
    ],
    "Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId" ],
    "Properties": {
        "Application": "MyApplication"
    },
    "AspNetCore": {
        "RequestLog": {
            "LogLevel": {
                "Default": "Warning",
                "Microsoft": "Warning",
                "Microsoft.AspNetCore.StaticFiles": "Warning"
            }
        }
    }
}

In the "Serilog.AspNetCore" section, under "RequestLog", you can see the "LogLevel" field. Change the value of "Default" to a higher level than "Information". For example, you can set it to "Warning" to turn off HTTP request tracking.

    "AspNetCore": {
        "RequestLog": {
            "LogLevel": {
                "Default": "Warning",
                "Microsoft": "Warning",
                "Microsoft.AspNetCore.StaticFiles": "Warning"
            }
        }
    }
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-06-20 21:34:48 +0000

Seen: 13 times

Last updated: Jun 20 '23