Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standardize and consolidate logging #8136

Closed
wants to merge 1 commit into from
Closed

Conversation

ajcvickers
Copy link
Contributor

Issues #7217 #218

This change:

  • Consolidates interception and sensitive logging into one service and uses that service everywhere in the EF code.
  • Adds a LoggerCategory class which contains nested classes that define EF logging categories.
  • Used together, this means any EF service can depend on IInterceptingLogger<TLoggingCategory> and have D.I. create the correct service using its open generics feature. The TLoggingCategory is constrained so that only types specifically defined as LoggingCategories can be used. For example, IInterceptingLogger<LoggingCategory.Database.Sql>.
  • Application code can get logging categories using, for example, LoggingCategory.Database.Sql.Name. This means that any application can immediately see in code what logging categories there are to do appropriate filtering.
  • All services depend on the specific generic IInterceptingLogger<TLoggingCategory> that they will use--never ILogger. This makes it very clear which category is being logged to and makes it safe to share loggers where safe, and impossible where the categories should be different.

@@ -76,7 +75,7 @@ protected DbContext()
: this(new DbContextOptions<DbContext>())
{
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove extra whitespace here and a couple of places below.

Issues #7217 #218

This change:
* Consolidates interception and sensitive logging into one service and uses that service everywhere in the EF code.
* Adds a LoggerCategory class which contains nested classes that define EF logging categories.
* Used together, this means any EF service can depend on `IInterceptingLogger<TLoggingCategory>` and have D.I. fill create the correct service using its open generics feature. The TLoggingCategory is constrained so that only types specifically defined as LoggingCategories can be used. For example, `IInterceptingLogger<LoggingCategory.Database.Sql>`.
* Application code can get logging categories using, for example, `LoggingCategory.Database.Sql.Name`. This means that any application can immediately see in code what logging categories there are to do appropriate filtering.
* All services depend on the specific generic `IInterceptingLogger<TLoggingCategory>` that they will use--never ILogger. This makes it very clear which category is being logged to and makes it safe to share loggers where safe, and impossible where the categories should be different.
@ajcvickers
Copy link
Contributor Author

Merged

@ajcvickers ajcvickers closed this Apr 13, 2017
@bricelam bricelam deleted the LoggyMcLogFace0405 branch April 18, 2017 17:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants