From 524bdc5fa0af3189311bfe7e1faf69dd20e3518d Mon Sep 17 00:00:00 2001 From: Arthur Vickers Date: Mon, 9 Nov 2020 12:29:39 -0800 Subject: [PATCH] Updating for new TOC --- .../diagnostic-listeners.md} | 8 ++++---- .../diagnostic-listeners.md.stub | 0 .../events.md} | 6 +++--- .../logging-events-diagnostics/events.md.stub | 0 .../extensions-logging.md | 6 +++--- .../extensions-logging.md.stub | 0 .../core/logging-events-diagnostics/index.md | 16 ++++++++-------- .../interceptors.md} | 8 ++++---- .../interceptors.md.stub | 0 .../logging-events-diagnostics/simple-logging.md | 2 +- entity-framework/toc.yml | 12 ++++++++---- 11 files changed, 31 insertions(+), 27 deletions(-) rename entity-framework/core/{miscellaneous/events/diagnostics.md => logging-events-diagnostics/diagnostic-listeners.md} (93%) delete mode 100644 entity-framework/core/logging-events-diagnostics/diagnostic-listeners.md.stub rename entity-framework/core/{miscellaneous/events/dotnet-events.md => logging-events-diagnostics/events.md} (94%) delete mode 100644 entity-framework/core/logging-events-diagnostics/events.md.stub rename entity-framework/core/{miscellaneous/events => logging-events-diagnostics}/extensions-logging.md (96%) delete mode 100644 entity-framework/core/logging-events-diagnostics/extensions-logging.md.stub rename entity-framework/core/{miscellaneous/events/interception.md => logging-events-diagnostics/interceptors.md} (98%) delete mode 100644 entity-framework/core/logging-events-diagnostics/interceptors.md.stub diff --git a/entity-framework/core/miscellaneous/events/diagnostics.md b/entity-framework/core/logging-events-diagnostics/diagnostic-listeners.md similarity index 93% rename from entity-framework/core/miscellaneous/events/diagnostics.md rename to entity-framework/core/logging-events-diagnostics/diagnostic-listeners.md index 93691f23dc..4b4dc8e5fc 100644 --- a/entity-framework/core/miscellaneous/events/diagnostics.md +++ b/entity-framework/core/logging-events-diagnostics/diagnostic-listeners.md @@ -3,19 +3,19 @@ title: Using diagnostic listeners - EF Core description: Using DiagnosticListener for global consumption of EF Core diagnostics author: ajcvickers ms.date: 10/16/2020 -uid: core/miscellaneous/events/diagnostics +uid: core/logging-events-diagnostics/diagnostic-listeners --- -# Using diagnostic listeners in EF Core +# Using Diagnostic Listeners in EF Core > [!TIP] > You can [download this article's sample](https://github.com/dotnet/EntityFramework.Docs/tree/master/samples/core/Miscellaneous/DiagnosticListeners) from GitHub. Diagnostic listeners allow listening for any EF Core event that occurs in the current .NET process. The class is a part of a [common mechanism across .NET](https://github.com/dotnet/runtime/blob/master/src/libraries/System.Diagnostics.DiagnosticSource/src/DiagnosticSourceUsersGuide.md) for obtaining diagnostic information from running applications. -Diagnostic listeners are not suitable for getting events from a single DbContext instance. EF Core [interceptors](xref:core/miscellaneous/events/interception) provide access to the same events with per-context registration. +Diagnostic listeners are not suitable for getting events from a single DbContext instance. EF Core [interceptors](xref:core/logging-events-diagnostics/interceptors) provide access to the same events with per-context registration. -Diagnostic listeners are not designed for logging. Consider using [simple logging](xref:core/miscellaneous/events/simple-logging) or [Microsoft.Extensions.Logging](xref:core/miscellaneous/events/extensions-logging) for logging. +Diagnostic listeners are not designed for logging. Consider using [simple logging](xref:core/logging-events-diagnostics/simple-logging) or [Microsoft.Extensions.Logging](xref:core/logging-events-diagnostics/extensions-logging) for logging. ## Example: Observing diagnostic events diff --git a/entity-framework/core/logging-events-diagnostics/diagnostic-listeners.md.stub b/entity-framework/core/logging-events-diagnostics/diagnostic-listeners.md.stub deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/entity-framework/core/miscellaneous/events/dotnet-events.md b/entity-framework/core/logging-events-diagnostics/events.md similarity index 94% rename from entity-framework/core/miscellaneous/events/dotnet-events.md rename to entity-framework/core/logging-events-diagnostics/events.md index 1a588c55ba..11d4201e7f 100644 --- a/entity-framework/core/miscellaneous/events/dotnet-events.md +++ b/entity-framework/core/logging-events-diagnostics/events.md @@ -3,7 +3,7 @@ title: .NET events - EF Core description: .NET events defined by EF Core author: ajcvickers ms.date: 10/15/2020 -uid: core/miscellaneous/events/dotnet-events +uid: core/logging-events-diagnostics/events --- # .NET events in EF Core @@ -11,9 +11,9 @@ uid: core/miscellaneous/events/dotnet-events > [!TIP] > You can [download the events sample](https://github.com/dotnet/EntityFramework.Docs/tree/master/samples/core/Miscellaneous/Events) from GitHub. -Entity Framework Core (EF Core) exposes [.NET events](/dotnet/standard/events/) to act as callbacks when certain things happen in the EF Core code. Events are simpler than [interceptors](xref:core/miscellaneous/events/interception) and allow more flexible registration. However, they are sync only and so cannot perform non-blocking async I/O. +Entity Framework Core (EF Core) exposes [.NET events](/dotnet/standard/events/) to act as callbacks when certain things happen in the EF Core code. Events are simpler than [interceptors](xref:core/logging-events-diagnostics/interceptors) and allow more flexible registration. However, they are sync only and so cannot perform non-blocking async I/O. -Events are registered per `DbContext` instance. Use a [diagnostic listener](xref:core/miscellaneous/events/diagnostics) to get the same information but for all DbContext instances in the process. +Events are registered per `DbContext` instance. Use a [diagnostic listener](xref:core/logging-events-diagnostics/diagnostic-listeners) to get the same information but for all DbContext instances in the process. ## Events raised by EF Core diff --git a/entity-framework/core/logging-events-diagnostics/events.md.stub b/entity-framework/core/logging-events-diagnostics/events.md.stub deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/entity-framework/core/miscellaneous/events/extensions-logging.md b/entity-framework/core/logging-events-diagnostics/extensions-logging.md similarity index 96% rename from entity-framework/core/miscellaneous/events/extensions-logging.md rename to entity-framework/core/logging-events-diagnostics/extensions-logging.md index 0cdab1bbc4..3f976badea 100644 --- a/entity-framework/core/miscellaneous/events/extensions-logging.md +++ b/entity-framework/core/logging-events-diagnostics/extensions-logging.md @@ -3,14 +3,14 @@ title: Using Microsoft.Extensions.Logging - EF Core description: Logging from EF Core using Microsoft.Extensions.Logging in ASP.NET Core and other application types author: ajcvickers ms.date: 10/15/2020 -uid: core/miscellaneous/events/extensions-logging +uid: core/logging-events-diagnostics/extensions-logging --- # Using Microsoft.Extensions.Logging in EF Core [Microsoft.Extensions.Logging](/dotnet/core/extensions/logging) is an extensible logging mechanism with plug-in providers for many common logging systems. Both Microsoft-supplied plug-ins (e.g [Microsoft.Extensions.Logging.Console](https://www.nuget.org/packages/Microsoft.Extensions.Logging.Console/)) and third-party plug-ins (e.g. [Serilog.Extensions.Logging](https://www.nuget.org/packages/Serilog.Extensions.Logging/)) are available as NuGet packages. -Entity Framework Core (EF Core) fully integrates with `Microsoft.Extensions.Logging`. However, consider using [simple logging](xref:core/miscellaneous/events/simple-logging) for a simpler way to log, especially for applications that don't use dependency injection. +Entity Framework Core (EF Core) fully integrates with `Microsoft.Extensions.Logging`. However, consider using [simple logging](xref:core/logging-events-diagnostics/simple-logging) for a simpler way to log, especially for applications that don't use dependency injection. ## ASP.NET Core applications @@ -20,7 +20,7 @@ Entity Framework Core (EF Core) fully integrates with `Microsoft.Extensions.Logg Other application types can use the [GenericHost](/dotnet/core/extensions/generic-host) to get the same dependency injection patterns as are used in ASP.NET Core. AddDbContext or AddDbContextPool can then be used just like in ASP.NET Core applications. -`Microsoft.Extensions.Logging` can also be used for applications that don't use dependency injection, although [simple logging](xref:core/miscellaneous/events/simple-logging) can be easier to set up. +`Microsoft.Extensions.Logging` can also be used for applications that don't use dependency injection, although [simple logging](xref:core/logging-events-diagnostics/simple-logging) can be easier to set up. `Microsoft.Extensions.Logging` requires creation of a . This factory should be stored as a static/global instance somewhere and used each time a DbContext is created. For example, it is common to store the logger factory as a static property on the DbContext. diff --git a/entity-framework/core/logging-events-diagnostics/extensions-logging.md.stub b/entity-framework/core/logging-events-diagnostics/extensions-logging.md.stub deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/entity-framework/core/logging-events-diagnostics/index.md b/entity-framework/core/logging-events-diagnostics/index.md index 13285b0f8a..fc6edfdb5e 100644 --- a/entity-framework/core/logging-events-diagnostics/index.md +++ b/entity-framework/core/logging-events-diagnostics/index.md @@ -47,7 +47,7 @@ See [Simple Logging](xref:core/logging-events-diagnostics/simple-logging) for mo EF Core fully integrates with `Microsoft.Extensions.Logging` and this form of logging is used by default for ASP.NET Core applications. -See [Using Microsoft.Extensions.Logging in EF Core](xref:core/miscellaneous/events/extensions-logging) for more information. +See [Using Microsoft.Extensions.Logging in EF Core](xref:core/logging-events-diagnostics/extensions-logging) for more information. ## Events @@ -56,9 +56,9 @@ See [Using Microsoft.Extensions.Logging in EF Core](xref:core/miscellaneous/even EF Core exposes [.NET events](/dotnet/standard/events/) to act as callbacks when certain things happen in the EF Core code. Events are simpler than interceptors and allow more flexible registration. However, they are sync only and so cannot perform non-blocking async I/O. -Events are registered per DbContext instance and this registration can be done at any time. Use a [diagnostic listener](xref:core/miscellaneous/events/diagnostics) to get the same information but for all DbContext instances in the process. +Events are registered per DbContext instance and this registration can be done at any time. Use a [diagnostic listener](xref:core/logging-events-diagnostics/diagnostic-Listeners) to get the same information but for all DbContext instances in the process. -See [.NET Events in EF Core](xref:core/miscellaneous/events/dotnet-events) for more information. +See [.NET Events in EF Core](xref:core/logging-events-diagnostics/events) for more information. ## Interception @@ -67,11 +67,11 @@ See [.NET Events in EF Core](xref:core/miscellaneous/events/dotnet-events) for m EF Core interceptors enable interception, modification, and/or suppression of EF Core events. This includes low-level database operations such as executing a command, as well as higher-level events, such as calls to SaveChanges. -Interceptors are different from logging and diagnostics in that they allow modification or suppression of the operation being intercepted. [Simple logging](xref:core/miscellaneous/events/simple-logging) or [Microsoft.Extensions.Logging](xref:core/miscellaneous/events/extensions-logging) are better choices for logging. +Interceptors are different from logging and diagnostics in that they allow modification or suppression of the operation being intercepted. [Simple logging](xref:core/logging-events-diagnostics/simple-logging) or [Microsoft.Extensions.Logging](xref:core/logging-events-diagnostics/extensions-logging) are better choices for logging. -Interceptors are registered per DbContext instance when the context is configured. Use a [diagnostic listener](xref:core/miscellaneous/events/diagnostics) to get the same information but for all DbContext instances in the process. +Interceptors are registered per DbContext instance when the context is configured. Use a [diagnostic listener](xref:core/logging-events-diagnostics/diagnostic-Listeners) to get the same information but for all DbContext instances in the process. -See [Interception](xref:core/miscellaneous/events/interception) for more information. +See [Interception](xref:core/logging-events-diagnostics/interception) for more information. ## Diagnostic listeners @@ -79,6 +79,6 @@ Diagnostic listeners allow listening for any EF Core event that occurs in the cu Diagnostic listeners are not suitable for getting events from a single DbContext instance. EF Core interceptors provide access to the same events with per-context registration. -Diagnostic listeners are not designed for logging. [Simple logging](xref:core/miscellaneous/events/simple-logging) or [Microsoft.Extensions.Logging](xref:core/miscellaneous/events/extensions-logging) are better choices for logging. +Diagnostic listeners are not designed for logging. [Simple logging](xref:core/logging-events-diagnostics/simple-logging) or [Microsoft.Extensions.Logging](xref:core/logging-events-diagnostics/extensions-logging) are better choices for logging. -See [Using diagnostic listeners in EF Core](xref:core/miscellaneous/events/diagnostics) for more information. +See [Using diagnostic listeners in EF Core](xref:core/logging-events-diagnostics/diagnostic-Listeners) for more information. diff --git a/entity-framework/core/miscellaneous/events/interception.md b/entity-framework/core/logging-events-diagnostics/interceptors.md similarity index 98% rename from entity-framework/core/miscellaneous/events/interception.md rename to entity-framework/core/logging-events-diagnostics/interceptors.md index ed75db0518..4b36e6f445 100644 --- a/entity-framework/core/miscellaneous/events/interception.md +++ b/entity-framework/core/logging-events-diagnostics/interceptors.md @@ -3,16 +3,16 @@ title: Interceptors - EF Core description: Interception for database operations and other events author: ajcvickers ms.date: 10/08/2020 -uid: core/miscellaneous/events/interception +uid: core/logging-events-diagnostics/interceptors --- # Interceptors Entity Framework Core (EF Core) interceptors enable interception, modification, and/or suppression of EF Core events. This includes low-level database operations such as executing a command, as well as higher-level events, such as calls to SaveChanges. -Interceptors are different from logging and diagnostics in that they allow modification or suppression of the operation being intercepted. [Simple logging](xref:core/miscellaneous/events/simple-logging) or [Microsoft.Extensions.Logging](xref:core/miscellaneous/events/extensions-logging) are better choices for logging. +Interceptors are different from logging and diagnostics in that they allow modification or suppression of the operation being intercepted. [Simple logging](xref:core/logging-events-diagnostics/simple-logging) or [Microsoft.Extensions.Logging](xref:core/logging-events-diagnostics/extensions-logging) are better choices for logging. -Interceptors are registered per DbContext instance when the context is configured. Use a [diagnostic listener](xref:core/miscellaneous/events/diagnostics) to get the same information but for all DbContext instances in the process. +Interceptors are registered per DbContext instance when the context is configured. Use a [diagnostic listener](xref:core/logging-events-diagnostics/diagnostic-listeners) to get the same information but for all DbContext instances in the process. ## Registering interceptors @@ -394,7 +394,7 @@ Notice from the log output that the application continues to use the cached mess and interception points are defined by the `ISaveChangesInterceptor` interface. As for other interceptors, the `SaveChangesInterceptor` base class with no-op methods is provided as a convenience. > [!TIP] -> Interceptors are powerful. However, in many cases it may be easier to override the SaveChanges method or use the [.NET events for SaveChanges](xref:core/miscellaneous/events/dotnet-events) exposed on DbContext. +> Interceptors are powerful. However, in many cases it may be easier to override the SaveChanges method or use the [.NET events for SaveChanges](xref:core/logging-events-diagnostics/events) exposed on DbContext. ### Example: SaveChanges interception for auditing diff --git a/entity-framework/core/logging-events-diagnostics/interceptors.md.stub b/entity-framework/core/logging-events-diagnostics/interceptors.md.stub deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/entity-framework/core/logging-events-diagnostics/simple-logging.md b/entity-framework/core/logging-events-diagnostics/simple-logging.md index e543c8a4c0..9e1d08dbf5 100644 --- a/entity-framework/core/logging-events-diagnostics/simple-logging.md +++ b/entity-framework/core/logging-events-diagnostics/simple-logging.md @@ -17,7 +17,7 @@ uid: core/logging-events-diagnostics/simple-logging Entity Framework Core (EF Core) simple logging can be used to easily obtain logs while developing and debugging applications. This form of logging requires minimal configuration and no additional NuGet packages. > [!TIP] -> EF Core also integrates with [Microsoft.Extensions.Logging](xref:core/miscellaneous/events/extensions-logging), which requires more configuration, but is often more suitable for logging in production applications. +> EF Core also integrates with [Microsoft.Extensions.Logging](xref:core/logging-events-diagnostics/extensions-logging), which requires more configuration, but is often more suitable for logging in production applications. ## Configuration diff --git a/entity-framework/toc.yml b/entity-framework/toc.yml index 148c350cc5..42d6e846d5 100644 --- a/entity-framework/toc.yml +++ b/entity-framework/toc.yml @@ -227,11 +227,15 @@ href: core/logging-events-diagnostics/index.md - name: Simple logging href: core/logging-events-diagnostics/simple-logging.md - #- name: Microsoft.Extensions.Logging + - name: Microsoft.Extensions.Logging + href: core/logging-events-diagnostics/extensions-logging.md #- name: ToQueryString - #- name: Events - #- name: Interceptors - #- name: Diagnostic listeners + - name: Events + href: core/logging-events-diagnostics/events.md + - name: Interceptors + href: core/logging-events-diagnostics/interceptos.md + - name: Diagnostic listeners + href: core/logging-events-diagnostics/diagnostic-listeners.md #- name: Debug views #- name: Event counters