This information relates to a pre-release product that may be substantially modified before it's commercially released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
W3CLogger is a middleware that writes log files in the W3C standard format. The logs contain information about HTTP requests and HTTP responses. W3CLogger provides logs of:
HTTP request information
Common properties
Headers
HTTP response information
Metadata about the request/response pair (date/time started, time taken)
W3CLogger is valuable in several scenarios to:
Record information about incoming requests and responses.
Filter which parts of the request and response are logged.
Filter which headers to log.
W3CLogger can reduce the performance of an app. Consider the performance impact when selecting fields to log - the performance reduction will increase as you log more properties. Test the performance impact of the selected logging properties.
Warning
W3CLogger can potentially log personally identifiable information (PII). Consider the risk and avoid logging sensitive information. By default, fields that could contain PII aren't logged.
Enable W3CLogger
Enable W3CLogger with UseW3CLogging, which adds the W3CLogger middleware:
var app = builder.Build();
app.UseW3CLogging();
app.UseRouting();
By default, W3CLogger logs common properties such as path, status-code, date, time, and protocol. All information about a single request/response pair is written to the same line.
W3CLoggerOptions.LoggingFields is a bit flag enumeration that configures specific parts of the request and response to log, and other information about the connection. LoggingFields defaults to include all possible fields except UserName and Cookie. For a complete list of available fields, see W3CLoggingFields.
W3CLogger is a middleware that writes log files in the W3C standard format. The logs contain information about HTTP requests and HTTP responses. W3CLogger provides logs of:
HTTP request information
Common properties
Headers
HTTP response information
Metadata about the request/response pair (date/time started, time taken)
W3CLogger is valuable in several scenarios to:
Record information about incoming requests and responses.
Filter which parts of the request and response are logged.
Filter which headers to log.
W3CLogger can reduce the performance of an app. Consider the performance impact when selecting fields to log - the performance reduction will increase as you log more properties. Test the performance impact of the selected logging properties.
Warning
W3CLogger can potentially log personally identifiable information (PII). Consider the risk and avoid logging sensitive information. By default, fields that could contain PII aren't logged.
Enable W3CLogger
Enable W3CLogger with UseW3CLogging, which adds the W3CLogger middleware:
var app = builder.Build();
app.UseW3CLogging();
app.UseRouting();
By default, W3CLogger logs common properties such as path, status-code, date, time, and protocol. All information about a single request/response pair is written to the same line.
W3CLoggerOptions.LoggingFields is a bit flag enumeration that configures specific parts of the request and response to log, and other information about the connection. LoggingFields defaults to include all possible fields except UserName and Cookie. For a complete list of available fields, see W3CLoggingFields.
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.
ASP.NET Core feedback
ASP.NET Core is an open source project. Select a link to provide feedback:
Understand and implement middleware in an ASP.NET Core app. Use included middleware like HTTP logging and authentication. Create custom middleware to handle requests and responses.