Skip to content

Commit

Permalink
Merge pull request #30288 from dotnet/log.create
Browse files Browse the repository at this point in the history
fix logger /7
  • Loading branch information
Rick-Anderson authored Sep 8, 2023
2 parents eb47387 + 4914aff commit 7b9118b
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions aspnetcore/fundamentals/logging/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,6 @@ Calling `CreateLogger` with a fixed name can be useful when used in multiple met

`ILogger<T>` is equivalent to calling `CreateLogger` with the fully qualified type name of `T`.

***NOTE:*** [LoggerFactory.Create](/dotnet/api/microsoft.extensions.logging.loggerfactory.create) Creates a new instance of <xref:Microsoft.Extensions.Logging.ILoggerFactory> that's configured using the provided `configure` delegate. The new instance of `ILoggerFactory` creates a new logging pipeline, different from the default logging pipeline. The new logging pipeline is not configured by the `Logging` section of `appsettings.json` or `appsettings.{ENVIRONMENT}.json`. For more information, see [Logging configuration](xref:fundamentals/logging/index#configure-logging).

<a name="llvl"></a>

## Log level
Expand Down Expand Up @@ -879,14 +877,19 @@ The following example shows how to register filter rules in code:

The logging libraries implicitly create a scope object with `SpanId`, `TraceId`, `ParentId`,`Baggage`, and `Tags`. This behavior is configured via <xref:Microsoft.Extensions.Logging.LoggerFactoryOptions.ActivityTrackingOptions>.

[!code-csharp[](~/fundamentals/logging/index/samples/6.x/WebApp/Program.cs?name=snippet4)]
[!code-csharp[](~/fundamentals/logging/index/samples/6.x/WebLog/Program.cs?name=snippet4)]

If the `traceparent` http request header is set, the `ParentId` in the log scope shows the W3C `parent-id` from in-bound `traceparent` header and the `SpanId` in the log scope shows the updated `parent-id` for the next out-bound step/span. For more information, see [Mutating the traceparent Field](https://www.w3.org/TR/trace-context/#mutating-the-traceparent-field).

## Create a custom logger

To create a custom logger, see [Implement a custom logging provider in .NET](/dotnet/core/extensions/custom-logging-provider).

<!-- See https://github.com/dotnet/AspNetCore.Docs/pull/30282#issuecomment-1712135965
## LoggerFactory.Create
***NOTE:*** [LoggerFactory.Create](/dotnet/api/microsoft.extensions.logging.loggerfactory.create) Creates a new instance of <xref:Microsoft.Extensions.Logging.ILoggerFactory> that's configured using the provided `configure` delegate. The new instance of `ILoggerFactory` creates a new logging pipeline, different from the default logging pipeline. The new logging pipeline is not configured by the `Logging` section of `appsettings.json` or `appsettings.{ENVIRONMENT}.json`. For more information, see [Logging configuration](xref:fundamentals/logging/index#configure-logging).
-->

## Additional resources

* [Microsoft.Extensions.Logging source on GitHub](https://github.com/dotnet/runtime/tree/main/src/libraries/Microsoft.Extensions.Logging)
Expand Down

0 comments on commit 7b9118b

Please sign in to comment.