You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: aspnetcore/fundamentals/logging/index.md
+14-14Lines changed: 14 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ description: Learn how to use the ASP.NET Core logging framework provided by the
6
6
monikerRange: '>= aspnetcore-3.1'
7
7
ms.author: tdykstra
8
8
ms.custom: mvc
9
-
ms.date: 09/30/2025
9
+
ms.date: 10/01/2025
10
10
uid: fundamentals/logging/index
11
11
---
12
12
# Logging in .NET and ASP.NET Core
@@ -475,7 +475,7 @@ setx Logging__LogLevel__Microsoft Information /M
475
475
> [!NOTE]
476
476
> When configuring environment variables with names that contain `.` (periods) in macOS and Linux, consider the "Exporting a variable with a dot (.) in it" question on **Stack Exchange** and its corresponding [accepted answer](https://unix.stackexchange.com/a/93533).
477
477
478
-
### Azure App Service
478
+
### Configure Azure App Service
479
479
480
480
On [Azure App Service](https://azure.microsoft.com/services/app-service/), follow the guidance in [Configure an App Service app](/azure/app-service/configure-common?tabs=portal#configure-app-settings) to set logging environment variables.
481
481
@@ -644,6 +644,10 @@ Log at an appropriate level to control how much log output is written to a parti
644
644
* We recommend the <xref:Microsoft.Extensions.Logging.LogLevel.Information> level (`"Default": "Information"`) for default logging and the <xref:Microsoft.Extensions.Logging.LogLevel.Warning> level for Microsoft ASP.NET Core assemblies (`"Microsoft.AspNetCore": "Warning"`).
645
645
* Add <xref:Microsoft.Extensions.Logging.LogLevel.Trace> and <xref:Microsoft.Extensions.Logging.LogLevel.Debug>, or <xref:Microsoft.Extensions.Logging.LogLevel.Information> messages when troubleshooting. To limit output, only set these logging levels for the categories under investigation.
646
646
647
+
## Change log levels in a running app
648
+
649
+
The Logging API doesn't include support for changing log levels while an app is running. However, some configuration providers are capable of reloading configuration, which takes immediate effect on logging configuration. For example, the [File Configuration Provider](xref:fundamentals/configuration/index#file-configuration-provider), reloads logging configuration by default. If configuration is changed in code while an app is running, the app can call <xref:Microsoft.Extensions.Configuration.IConfigurationRoot.Reload%2A?displayProperty=nameWithType> to update the app's logging configuration.
650
+
647
651
## How filtering rules are applied
648
652
649
653
When an <xref:Microsoft.Extensions.Logging.ILogger%601> object is created, the <xref:Microsoft.Extensions.Logging.ILoggerFactory> object selects a single rule per provider to apply to that logger. All messages written by an <xref:Microsoft.Extensions.Logging.ILogger> instance are filtered based on the selected rules. The most specific rule for each provider and category pair is selected from the available rules.
@@ -694,6 +698,13 @@ When logging to Azure Table Storage:
694
698
* Each Azure Table entity can have `ID` and `RequestTime` properties.
695
699
* Tables with properties simplify queries on logged data. For example, a query can find all logs within a particular `RequestTime` range without having to parse the time out of the text message.
696
700
701
+
## `ILogger` and `ILoggerFactory`
702
+
703
+
The <xref:Microsoft.Extensions.Logging.ILogger%601> and <xref:Microsoft.Extensions.Logging.ILoggerFactory> interfaces and implementations are included in the .NET SDK. They are also available in the following NuGet packages:
704
+
705
+
* The interfaces are in the [`Microsoft.Extensions.Logging.Abstractions` NuGet package](https://www.nuget.org/packages/Microsoft.Extensions.Logging.Abstractions).
706
+
* The default implementations are in the [`Microsoft.Extensions.Logging` NuGet package](https://www.nuget.org/packages/microsoft.extensions.logging).
707
+
697
708
## Log exceptions
698
709
699
710
The logger methods have overloads that take an exception parameter:
When the app calls the <xref:Microsoft.Extensions.Logging.EventLoggerFactoryExtensions.AddEventLog%2A> overload with <xref:Microsoft.Extensions.Logging.EventLog.EventLogSettings>, a new instance of <xref:Microsoft.Extensions.Logging.EventLog.EventLogLoggerProvider> is created with the provided settings. If there's already an <xref:Microsoft.Extensions.Logging.EventLog.EventLogLoggerProvider> instance registered, which is the case if the app doesn't call <xref:Microsoft.Extensions.Logging.LoggingBuilderExtensions.ClearProviders%2A> to remove all the <xref:Microsoft.Extensions.Logging.ILoggerProvider> instances, the new settings don't replace the existing ones. If you want to ensure that the <xref:Microsoft.Extensions.Logging.EventLog.EventLogSettings> are used, call <xref:Microsoft.Extensions.Logging.LoggingBuilderExtensions.ClearProviders%2A> before calling <xref:Microsoft.Extensions.Logging.EventLoggerFactoryExtensions.AddEventLog%2A>.
1094
1105
1095
-
### Azure App Service
1106
+
####Azure App Service
1096
1107
1097
1108
The [`Microsoft.Extensions.Logging.AzureAppServices` provider NuGet package](https://www.nuget.org/packages/Microsoft.Extensions.Logging.AzureAppServices) writes logs to text files in an Azure App Service app's file system and to [blob storage](/azure/storage/blobs/storage-quickstart-blobs-dotnet#what-is-blob-storage) in an Azure Storage account. The provider only logs when the project runs in the Azure environment.
1098
1109
@@ -1231,17 +1242,6 @@ For logging in a console app without the Generic Host, see [Logging in C# and .N
1231
1242
1232
1243
Logging should be so fast that it isn't worth the performance cost of asynchronous code. If a logging data store is slow, don't write to it directly. Consider writing the log messages to a fast store initially, then move the logs to the slower data store later. For example, don't write log messages directly to a SQL Server data store in a `Log` method because `Log` methods are synchronous. Instead, synchronously add log messages to an in-memory queue and have a background worker pull the messages out of the queue to push the data to SQL Server asynchronously. For more information, see [Guidance on how to log to a message queue for slow data stores (dotnet/AspNetCore.Docs #11801)](https://github.com/dotnet/AspNetCore.Docs/issues/11801).
1233
1244
1234
-
## Change log levels in a running app
1235
-
1236
-
The Logging API doesn't include support for changing log levels while an app is running. However, some configuration providers are capable of reloading configuration, which takes immediate effect on logging configuration. For example, the [File Configuration Provider](xref:fundamentals/configuration/index#file-configuration-provider), reloads logging configuration by default. If configuration is changed in code while an app is running, the app can call <xref:Microsoft.Extensions.Configuration.IConfigurationRoot.Reload%2A?displayProperty=nameWithType> to update the app's logging configuration.
1237
-
1238
-
## `ILogger` and `ILoggerFactory`
1239
-
1240
-
The <xref:Microsoft.Extensions.Logging.ILogger%601> and <xref:Microsoft.Extensions.Logging.ILoggerFactory> interfaces and implementations are included in the .NET SDK. They are also available in the following NuGet packages:
1241
-
1242
-
* The interfaces are in the [`Microsoft.Extensions.Logging.Abstractions` NuGet package](https://www.nuget.org/packages/Microsoft.Extensions.Logging.Abstractions).
1243
-
* The default implementations are in the [`Microsoft.Extensions.Logging` NuGet package](https://www.nuget.org/packages/microsoft.extensions.logging).
1244
-
1245
1245
## Apply log filter rules in code
1246
1246
1247
1247
The preferred approach for setting log filter rules is by [app configuration](xref:fundamentals/configuration/index).
0 commit comments