Surface link to console provider options (#13250)
parent
80c03f0a00
commit
dbd4d1535e
|
@ -4,7 +4,7 @@ author: tdykstra
|
|||
description: Learn about the logging framework in ASP.NET Core. Discover the built-in logging providers and learn more about popular third-party providers.
|
||||
ms.author: tdykstra
|
||||
ms.custom: mvc
|
||||
ms.date: 05/01/2019
|
||||
ms.date: 07/11/2019
|
||||
uid: fundamentals/logging/index
|
||||
---
|
||||
# Logging in ASP.NET Core
|
||||
|
@ -45,7 +45,7 @@ If you use `CreateDefaultBuilder`, you can replace the default providers with yo
|
|||
|
||||
To use a provider, install its NuGet package and call the provider's extension method on an instance of <xref:Microsoft.Extensions.Logging.ILoggerFactory>:
|
||||
|
||||
[!code-csharp[](index/samples/1.x/TodoApiSample//Startup.cs?name=snippet_AddConsoleAndDebug&highlight=3,5-7)]
|
||||
[!code-csharp[](index/samples/1.x/TodoApiSample/Startup.cs?name=snippet_AddConsoleAndDebug&highlight=3,5-7)]
|
||||
|
||||
ASP.NET Core [dependency injection (DI)](xref:fundamentals/dependency-injection) provides the `ILoggerFactory` instance. The `AddConsole` and `AddDebug` extension methods are defined in the [Microsoft.Extensions.Logging.Console](https://www.nuget.org/packages/Microsoft.Extensions.Logging.Console/) and [Microsoft.Extensions.Logging.Debug](https://www.nuget.org/packages/Microsoft.Extensions.Logging.Debug/) packages. Each extension method calls the `ILoggerFactory.AddProvider` method, passing in an instance of the provider.
|
||||
|
||||
|
@ -639,6 +639,8 @@ loggerFactory.AddConsole();
|
|||
|
||||
[AddConsole overloads](xref:Microsoft.Extensions.Logging.ConsoleLoggerExtensions) let you pass in a minimum log level, a filter function, and a boolean that indicates whether scopes are supported. Another option is to pass in an `IConfiguration` object, which can specify scopes support and logging levels.
|
||||
|
||||
For Console provider options, see <xref:Microsoft.Extensions.Logging.Console.ConsoleLoggerOptions>.
|
||||
|
||||
The console provider has a significant impact on performance and is generally not appropriate for use in production.
|
||||
|
||||
When you create a new project in Visual Studio, the `AddConsole` method looks like this:
|
||||
|
@ -649,7 +651,7 @@ loggerFactory.AddConsole(Configuration.GetSection("Logging"));
|
|||
|
||||
This code refers to the `Logging` section of the *appSettings.json* file:
|
||||
|
||||
[!code-json[](index/samples/1.x/TodoApiSample//appsettings.json)]
|
||||
[!code-json[](index/samples/1.x/TodoApiSample/appsettings.json)]
|
||||
|
||||
The settings shown limit framework logs to warnings while allowing the app to log at debug level, as explained in the [Log filtering](#log-filtering) section. For more information, see [Configuration](xref:fundamentals/configuration/index).
|
||||
|
||||
|
|
Loading…
Reference in New Issue