From d1b5b1be4fb626d2bf5c67897d8a8b2cc6d914eb Mon Sep 17 00:00:00 2001 From: Skyrunner-Dev-ops Date: Wed, 7 Oct 2026 23:38:43 +0530 Subject: [PATCH 1/7] Clarify W3CLogger service registration and default log location (#33592) --- aspnetcore/fundamentals/w3c-logger/index.md | 49 +++++++++++++++++---- 1 file changed, 41 insertions(+), 8 deletions(-) diff --git a/aspnetcore/fundamentals/w3c-logger/index.md b/aspnetcore/fundamentals/w3c-logger/index.md index 114cd536cd6a..6d807585ada5 100644 --- a/aspnetcore/fundamentals/w3c-logger/index.md +++ b/aspnetcore/fundamentals/w3c-logger/index.md @@ -4,7 +4,7 @@ author: wtgodbe description: Learn how to create server logs in the W3C standard format. monikerRange: '>= aspnetcore-6.0' ms.author: wpickett -ms.date: 08/15/2022 +ms.date: 10/07/2026 ms.reviewer: wigodbe uid: fundamentals/w3c-logger/index --- @@ -36,10 +36,17 @@ W3CLogger ***can reduce the performance of an app***. Consider the performance i ## Enable W3CLogger -Enable W3CLogger with , which adds the W3CLogger middleware: +To enable W3CLogger: + +1. Call to add the W3CLogger services to the dependency injection container. +1. Call to add the W3CLogger middleware to the request processing pipeline: + +:::code language="csharp" source="samples/6.x/Program.cs" id="snippet_AddW3CLogging" highlight="3"::: :::code language="csharp" source="samples/6.x/Program.cs" id="snippet_UseW3CLogging" highlight="3"::: +By default, log files are written to a `logs` directory in the application's content root directory (`./logs/`), with the file name prefix `w3clog-` (for example, `./logs/w3clog-20210929.0000.txt`). + 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. ``` @@ -53,9 +60,18 @@ By default, W3CLogger logs common properties such as path, status-code, date, ti ## W3CLogger options -To configure the W3CLogger middleware, call in `Program.cs`: +To configure the W3CLogger middleware, call and configure in `Program.cs`: -:::code language="csharp" source="samples/6.x/Program.cs" id="snippet_AddW3CLogging" highlight="3"::: +:::code language="csharp" source="samples/6.x/Program.cs" id="snippet_AddW3CLogging" highlight="3-13"::: + + supports the following properties: + +* : The log file name prefix. Defaults to `w3clog-`. +* : The maximum log file size in bytes before a new file is created. Defaults to 10 MiB (`10 * 1024 * 1024`). +* : The period after which logs are flushed to disk. Defaults to 1 second. +* : The directory where log files are written. Defaults to `./logs/` relative to the app's content root directory. +* : The maximum number of retained log files. Defaults to 4. +* : A bit flag enumeration that configures specific parts of the request and response to log, and other information about the connection. Defaults to include all possible fields except `UserName` and `Cookie`. For a complete list of available fields, see . ### `LoggingFields` @@ -86,9 +102,16 @@ W3CLogger ***can reduce the performance of an app***. Consider the performance i ## Enable W3CLogger -Enable W3CLogger with , which adds the W3CLogger middleware: +To enable W3CLogger: -:::code language="csharp" source="samples/6.x/Program.cs" id="snippet_UseW3CLogging" highlight="3"::: +1. Call to add the W3CLogger services to the dependency injection container. +1. Call to add the W3CLogger middleware to the request processing pipeline: + +:::code language="csharp" source="samples/7.x/Program.cs" id="snippet_AddW3CLogging" highlight="3"::: + +:::code language="csharp" source="samples/7.x/Program.cs" id="snippet_UseW3CLogging" highlight="3"::: + +By default, log files are written to a `logs` directory in the application's content root directory (`./logs/`), with the file name prefix `w3clog-` (for example, `./logs/w3clog-20210929.0000.txt`). 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. @@ -103,9 +126,19 @@ By default, W3CLogger logs common properties such as path, status-code, date, ti ## W3CLogger options -To configure the W3CLogger middleware, call in `Program.cs`: +To configure the W3CLogger middleware, call and configure in `Program.cs`: -:::code language="csharp" source="samples/7.x/Program.cs" id="snippet_AddW3CLogging" highlight="3"::: +:::code language="csharp" source="samples/7.x/Program.cs" id="snippet_AddW3CLogging" highlight="3-15"::: + + supports the following properties: + +* : Additional request headers to include in the log file. +* : The log file name prefix. Defaults to `w3clog-`. +* : The maximum log file size in bytes before a new file is created. Defaults to 10 MiB (`10 * 1024 * 1024`). +* : The period after which logs are flushed to disk. Defaults to 1 second. +* : The directory where log files are written. Defaults to `./logs/` relative to the app's content root directory. +* : The maximum number of retained log files. Defaults to 4. +* : A bit flag enumeration that configures specific parts of the request and response to log, and other information about the connection. Defaults to include all possible fields except `UserName` and `Cookie`. For a complete list of available fields, see . ### `LoggingFields` From 1d480692f9674058fbe40b8f066f30fcb8e04fa5 Mon Sep 17 00:00:00 2001 From: Skyrunner-Dev-ops Date: Thu, 8 Oct 2026 22:39:40 +0530 Subject: [PATCH 2/7] Address review feedback on W3CLogger documentation --- aspnetcore/fundamentals/w3c-logger/index.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/aspnetcore/fundamentals/w3c-logger/index.md b/aspnetcore/fundamentals/w3c-logger/index.md index 6d807585ada5..ecff1f95b1fd 100644 --- a/aspnetcore/fundamentals/w3c-logger/index.md +++ b/aspnetcore/fundamentals/w3c-logger/index.md @@ -39,13 +39,13 @@ W3CLogger ***can reduce the performance of an app***. Consider the performance i To enable W3CLogger: 1. Call to add the W3CLogger services to the dependency injection container. -1. Call to add the W3CLogger middleware to the request processing pipeline: +1. Call to add the W3CLogger middleware to the request processing pipeline. :::code language="csharp" source="samples/6.x/Program.cs" id="snippet_AddW3CLogging" highlight="3"::: :::code language="csharp" source="samples/6.x/Program.cs" id="snippet_UseW3CLogging" highlight="3"::: -By default, log files are written to a `logs` directory in the application's content root directory (`./logs/`), with the file name prefix `w3clog-` (for example, `./logs/w3clog-20210929.0000.txt`). +By default, log files are written to a `logs` directory in the app's content root directory (`./logs/`) with the file name prefix `w3clog-` (for example, `./logs/w3clog-20210929.0000.txt`). 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. @@ -67,11 +67,11 @@ To configure the W3CLogger middleware, call supports the following properties: * : The log file name prefix. Defaults to `w3clog-`. -* : The maximum log file size in bytes before a new file is created. Defaults to 10 MiB (`10 * 1024 * 1024`). +* : The maximum log file size in bytes before a new file is created. Defaults to 10 MB (`10 * 1024 * 1024`). * : The period after which logs are flushed to disk. Defaults to 1 second. * : The directory where log files are written. Defaults to `./logs/` relative to the app's content root directory. * : The maximum number of retained log files. Defaults to 4. -* : A bit flag enumeration that configures specific parts of the request and response to log, and other information about the connection. Defaults to include all possible fields except `UserName` and `Cookie`. For a complete list of available fields, see . +* : A bit flag enumeration that configures specific parts of the request and response to log and other information about the connection. Defaults to include all possible fields except `UserName` and `Cookie`. For a complete list of available fields, see . ### `LoggingFields` @@ -105,13 +105,13 @@ W3CLogger ***can reduce the performance of an app***. Consider the performance i To enable W3CLogger: 1. Call to add the W3CLogger services to the dependency injection container. -1. Call to add the W3CLogger middleware to the request processing pipeline: +1. Call to add the W3CLogger middleware to the request processing pipeline. :::code language="csharp" source="samples/7.x/Program.cs" id="snippet_AddW3CLogging" highlight="3"::: :::code language="csharp" source="samples/7.x/Program.cs" id="snippet_UseW3CLogging" highlight="3"::: -By default, log files are written to a `logs` directory in the application's content root directory (`./logs/`), with the file name prefix `w3clog-` (for example, `./logs/w3clog-20210929.0000.txt`). +By default, log files are written to a `logs` directory in the app's content root directory (`./logs/`) with the file name prefix `w3clog-` (for example, `./logs/w3clog-20210929.0000.txt`). 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. @@ -134,11 +134,11 @@ To configure the W3CLogger middleware, call : Additional request headers to include in the log file. * : The log file name prefix. Defaults to `w3clog-`. -* : The maximum log file size in bytes before a new file is created. Defaults to 10 MiB (`10 * 1024 * 1024`). +* : The maximum log file size in bytes before a new file is created. Defaults to 10 MB (`10 * 1024 * 1024`). * : The period after which logs are flushed to disk. Defaults to 1 second. * : The directory where log files are written. Defaults to `./logs/` relative to the app's content root directory. * : The maximum number of retained log files. Defaults to 4. -* : A bit flag enumeration that configures specific parts of the request and response to log, and other information about the connection. Defaults to include all possible fields except `UserName` and `Cookie`. For a complete list of available fields, see . +* : A bit flag enumeration that configures specific parts of the request and response to log and other information about the connection. Defaults to include all possible fields except `UserName` and `Cookie`. For a complete list of available fields, see . ### `LoggingFields` From c14214a1ce34271c684cd292104ec3f22ab29de5 Mon Sep 17 00:00:00 2001 From: Skyrunner-Dev-ops Date: Thu, 8 Oct 2026 23:07:06 +0530 Subject: [PATCH 3/7] Remove author and ms.author metadata per review feedback --- aspnetcore/fundamentals/w3c-logger/index.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/aspnetcore/fundamentals/w3c-logger/index.md b/aspnetcore/fundamentals/w3c-logger/index.md index ecff1f95b1fd..05eb5475879c 100644 --- a/aspnetcore/fundamentals/w3c-logger/index.md +++ b/aspnetcore/fundamentals/w3c-logger/index.md @@ -1,10 +1,8 @@ --- title: W3CLogger in .NET and ASP.NET Core -author: wtgodbe description: Learn how to create server logs in the W3C standard format. monikerRange: '>= aspnetcore-6.0' -ms.author: wpickett -ms.date: 10/07/2026 +ms.date: 10/08/2026 ms.reviewer: wigodbe uid: fundamentals/w3c-logger/index --- From 223e41c89a52758b96254fed1a241ff46dff5476 Mon Sep 17 00:00:00 2001 From: Luke Latham <1622880+guardrex@users.noreply.github.com> Date: Fri, 9 Oct 2026 09:08:42 -0400 Subject: [PATCH 4/7] Update W3CLogger documentation for clarity --- aspnetcore/fundamentals/w3c-logger/index.md | 32 ++++++++++++++------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/aspnetcore/fundamentals/w3c-logger/index.md b/aspnetcore/fundamentals/w3c-logger/index.md index ccc5f4068ff2..550b45a1ab89 100644 --- a/aspnetcore/fundamentals/w3c-logger/index.md +++ b/aspnetcore/fundamentals/w3c-logger/index.md @@ -32,14 +32,20 @@ W3CLogger ***can reduce the performance of an app***. Consider the performance i ## Enable W3CLogger -To enable W3CLogger: +Call to add the W3CLogger services to the dependency injection container: -1. Call to add the W3CLogger services to the dependency injection container. -1. Call to add the W3CLogger middleware to the request processing pipeline. +```csharp +builder.Services.AddW3CLogging(logging => +{ + // Set logging properties here +}); +``` -:::code language="csharp" source="samples/6.x/Program.cs" id="snippet_AddW3CLogging" highlight="3"::: +Next, call to add the W3CLogger middleware to the request processing pipeline. -:::code language="csharp" source="samples/6.x/Program.cs" id="snippet_UseW3CLogging" highlight="3"::: +```csharp +app.UseW3CLogging(); +``` By default, log files are written to a `logs` directory in the app's content root directory (`./logs/`) with the file name prefix `w3clog-` (for example, `./logs/w3clog-20210929.0000.txt`). @@ -98,14 +104,20 @@ W3CLogger ***can reduce the performance of an app***. Consider the performance i ## Enable W3CLogger -To enable W3CLogger: +Call to add the W3CLogger services to the dependency injection container: -1. Call to add the W3CLogger services to the dependency injection container. -1. Call to add the W3CLogger middleware to the request processing pipeline. +```csharp +builder.Services.AddW3CLogging(logging => +{ + // Set logging properties here +}); +``` -:::code language="csharp" source="samples/7.x/Program.cs" id="snippet_AddW3CLogging" highlight="3"::: +Next, call to add the W3CLogger middleware to the request processing pipeline. -:::code language="csharp" source="samples/7.x/Program.cs" id="snippet_UseW3CLogging" highlight="3"::: +```csharp +app.UseW3CLogging(); +``` By default, log files are written to a `logs` directory in the app's content root directory (`./logs/`) with the file name prefix `w3clog-` (for example, `./logs/w3clog-20210929.0000.txt`). From 04e045416e8d0e5322987a80fa0108df18e4505a Mon Sep 17 00:00:00 2001 From: Luke Latham <1622880+guardrex@users.noreply.github.com> Date: Fri, 9 Oct 2026 09:09:24 -0400 Subject: [PATCH 5/7] Improve clarity in W3CLogger middleware instructions Corrected the sentence structure for clarity regarding adding the W3CLogger middleware. --- aspnetcore/fundamentals/w3c-logger/index.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/aspnetcore/fundamentals/w3c-logger/index.md b/aspnetcore/fundamentals/w3c-logger/index.md index 550b45a1ab89..aebe3d999f4c 100644 --- a/aspnetcore/fundamentals/w3c-logger/index.md +++ b/aspnetcore/fundamentals/w3c-logger/index.md @@ -41,7 +41,7 @@ builder.Services.AddW3CLogging(logging => }); ``` -Next, call to add the W3CLogger middleware to the request processing pipeline. +Next, call to add the W3CLogger middleware to the request processing pipeline: ```csharp app.UseW3CLogging(); @@ -113,7 +113,7 @@ builder.Services.AddW3CLogging(logging => }); ``` -Next, call to add the W3CLogger middleware to the request processing pipeline. +Next, call to add the W3CLogger middleware to the request processing pipeline: ```csharp app.UseW3CLogging(); From 7fb1bb746c0029fd62663ca87da5f522c04b9f32 Mon Sep 17 00:00:00 2001 From: Luke Latham <1622880+guardrex@users.noreply.github.com> Date: Fri, 9 Oct 2026 09:17:04 -0400 Subject: [PATCH 6/7] Remove duplicate LoggingFields section from index.md Removed redundant section on LoggingFields from documentation. --- aspnetcore/fundamentals/w3c-logger/index.md | 8 -------- 1 file changed, 8 deletions(-) diff --git a/aspnetcore/fundamentals/w3c-logger/index.md b/aspnetcore/fundamentals/w3c-logger/index.md index aebe3d999f4c..84d785fa968a 100644 --- a/aspnetcore/fundamentals/w3c-logger/index.md +++ b/aspnetcore/fundamentals/w3c-logger/index.md @@ -75,10 +75,6 @@ To configure the W3CLogger middleware, call : The maximum number of retained log files. Defaults to 4. * : A bit flag enumeration that configures specific parts of the request and response to log and other information about the connection. Defaults to include all possible fields except `UserName` and `Cookie`. For a complete list of available fields, see . -### `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 . - ::: moniker-end :::moniker range=">= aspnetcore-7.0" @@ -148,8 +144,4 @@ To configure the W3CLogger middleware, call : The maximum number of retained log files. Defaults to 4. * : A bit flag enumeration that configures specific parts of the request and response to log and other information about the connection. Defaults to include all possible fields except `UserName` and `Cookie`. For a complete list of available fields, see . -### `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 . - ::: moniker-end From 3249ef4b4eaf01875f583a139e6214f60851157b Mon Sep 17 00:00:00 2001 From: Luke Latham <1622880+guardrex@users.noreply.github.com> Date: Fri, 9 Oct 2026 09:23:34 -0400 Subject: [PATCH 7/7] Update W3CLoggerOptions FileSizeLimit description --- aspnetcore/fundamentals/w3c-logger/index.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/aspnetcore/fundamentals/w3c-logger/index.md b/aspnetcore/fundamentals/w3c-logger/index.md index 84d785fa968a..29caaf807fa3 100644 --- a/aspnetcore/fundamentals/w3c-logger/index.md +++ b/aspnetcore/fundamentals/w3c-logger/index.md @@ -69,7 +69,7 @@ To configure the W3CLogger middleware, call supports the following properties: * : The log file name prefix. Defaults to `w3clog-`. -* : The maximum log file size in bytes before a new file is created. Defaults to 10 MB (`10 * 1024 * 1024`). +* : Gets or sets a strictly positive value representing the maximum log size in bytes or null for no limit. Once the log is full, no more messages will be appended. Defaults to 10MB (10 * 1024 * 1024). * : The period after which logs are flushed to disk. Defaults to 1 second. * : The directory where log files are written. Defaults to `./logs/` relative to the app's content root directory. * : The maximum number of retained log files. Defaults to 4. @@ -138,7 +138,7 @@ To configure the W3CLogger middleware, call : Additional request headers to include in the log file. * : The log file name prefix. Defaults to `w3clog-`. -* : The maximum log file size in bytes before a new file is created. Defaults to 10 MB (`10 * 1024 * 1024`). +* : Gets or sets a strictly positive value representing the maximum log size in bytes or null for no limit. Once the log is full, no more messages will be appended. Defaults to 10MB (10 * 1024 * 1024). * : The period after which logs are flushed to disk. Defaults to 1 second. * : The directory where log files are written. Defaults to `./logs/` relative to the app's content root directory. * : The maximum number of retained log files. Defaults to 4.