dotnet / dotnet/aspnetcore

Add custom format support to HttpLogging middleware

Open
#46,989 8 comments 59 reactions 0 assignees View on GitHub
area-middleware feature-diagnostics feature-http-logging
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 10h
Merged PRs (30d)
281

Description

In production i want to log each http request in the format I select. With HttpLogging I can selected Headers and LoggingFields but I cannot format the result, which looks something like this.

![image](https://user-images.githubusercontent.com/45663203/222454574-319c5b93-f584-4aad-88cb-a6d8cedc6d12.png)

I need to be able create single line logs and reorder logged properties

### Describe the solution you'd like

In `HttpLoggingOptions` I would like to be able to specify string format. It would look something like this:

```
builder.Services.AddHttpLogging(options =>
{
options.LogFormat = "Protocol {HttpProtocol} Scheme: {RequestScheme} \n Path: {Path}";
});

```

### Additional context

_No response_

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.