dotnet / dotnet/aspnetcore

Add support for configurable log level for http logging

Open
#36,841 10 comments 0 reactions 0 assignees View on GitHub
api-suggestion area-networking Needs: Design
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 5h
Merged PRs (30d)
276

Description

### Is your feature request related to a problem? Please describe.

I'd like to log the request with the `Error` log level when the response status is 4xx or 5xx, for others log as `Information`.

### Describe the solution you'd like

Currently, the log level is `Information` as I could see, maybe we could add a delegate to decide the logLevel in the `HttpLoggingOptions`, and keep it as `Information` by default

``` c#
public Func LogLevelFactory { get; set; } = context => LogLevel.Information;
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.