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

Simple Logging API for all logs #16200

Closed
ajcvickers opened this issue Jun 21, 2019 · 0 comments · Fixed by #18936
Closed

Simple Logging API for all logs #16200

ajcvickers opened this issue Jun 21, 2019 · 0 comments · Fixed by #18936
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-enhancement
Milestone

Comments

@ajcvickers
Copy link
Member

Like context.Database.Log from #1199, but not just for database interactions.

@ajcvickers ajcvickers self-assigned this Jun 21, 2019
@ajcvickers ajcvickers added this to the Backlog milestone Jun 24, 2019
ajcvickers added a commit that referenced this issue Nov 15, 2019
Fixes #16200
Fixes #1199

Examples:

Log to the Console:

```C#
protected override void OnConfiguring(DbContextOptionsBuilder options)
    => options
	    .UseMyProvider("...")
		.LogTo(Console.WriteLine);
```

Log to the Console for a given level:

```C#
protected override void OnConfiguring(DbContextOptionsBuilder options)
    => options
	    .UseMyProvider("...")
		.LogTo(Console.WriteLine, LogLevel.Information));
```

Log to the Console for specific events:

```C#
protected override void OnConfiguring(DbContextOptionsBuilder options)
    => options
	    .UseMyProvider("...")
		.LogTo(Console.WriteLine, new[] { CoreEventId.ContextInitialized, CoreEventId.ContextDisposed }));
```

Log to the Console for specific categories:

```C#
protected override void OnConfiguring(DbContextOptionsBuilder options)
    => options
	    .UseMyProvider("...")
		.LogTo(Console.WriteLine, new[] { DbLoggerCategory.Infrastructure.Name, DbLoggerCategory.Update.Name }));
```

Log to the Console with custom filter:

```C#
protected override void OnConfiguring(DbContextOptionsBuilder options)
    => options
	    .UseMyProvider("...")
		.LogTo(Console.WriteLine, (e, l) => e == CoreEventId.SaveChangesCompleted)));
```

Log to the Console for events in specific categories and a given level formatted as a single line using UTC timestamps:

```C#
protected override void OnConfiguring(DbContextOptionsBuilder options)
    => options
	    .UseMyProvider("...")
		.LogTo(
		    Console.WriteLine,
			new[] { DbLoggerCategory.Infrastructure.Name, DbLoggerCategory.Update.Name },
			LogLevel.Information,
			SimpleLoggerFormatOptions.SingleLine | SimpleLoggerFormatOptions.DefaultWithUtcTime | ));
```
@ajcvickers ajcvickers modified the milestones: Backlog, 5.0.0 Nov 15, 2019
ajcvickers added a commit that referenced this issue Nov 23, 2019
Fixes #16200
Fixes #1199

Examples:

Log to the Console:

```C#
protected override void OnConfiguring(DbContextOptionsBuilder options)
    => options
	    .UseMyProvider("...")
		.LogTo(Console.WriteLine);
```

Log to the Console for a given level:

```C#
protected override void OnConfiguring(DbContextOptionsBuilder options)
    => options
	    .UseMyProvider("...")
		.LogTo(Console.WriteLine, LogLevel.Information));
```

Log to the Console for specific events:

```C#
protected override void OnConfiguring(DbContextOptionsBuilder options)
    => options
	    .UseMyProvider("...")
		.LogTo(Console.WriteLine, new[] { CoreEventId.ContextInitialized, CoreEventId.ContextDisposed }));
```

Log to the Console for specific categories:

```C#
protected override void OnConfiguring(DbContextOptionsBuilder options)
    => options
	    .UseMyProvider("...")
		.LogTo(Console.WriteLine, new[] { DbLoggerCategory.Infrastructure.Name, DbLoggerCategory.Update.Name }));
```

Log to the Console with custom filter:

```C#
protected override void OnConfiguring(DbContextOptionsBuilder options)
    => options
	    .UseMyProvider("...")
		.LogTo(Console.WriteLine, (e, l) => e == CoreEventId.SaveChangesCompleted)));
```

Log to the Console for events in specific categories and a given level formatted as a single line using UTC timestamps:

```C#
protected override void OnConfiguring(DbContextOptionsBuilder options)
    => options
	    .UseMyProvider("...")
		.LogTo(
		    Console.WriteLine,
			new[] { DbLoggerCategory.Infrastructure.Name, DbLoggerCategory.Update.Name },
			LogLevel.Information,
			SimpleLoggerFormatOptions.SingleLine | SimpleLoggerFormatOptions.DefaultWithUtcTime | ));
```
ajcvickers added a commit that referenced this issue Nov 25, 2019
Fixes #16200
Fixes #1199

Examples:

Log to the Console:

```C#
protected override void OnConfiguring(DbContextOptionsBuilder options)
    => options
	    .UseMyProvider("...")
		.LogTo(Console.WriteLine);
```

Log to the Console for a given level:

```C#
protected override void OnConfiguring(DbContextOptionsBuilder options)
    => options
	    .UseMyProvider("...")
		.LogTo(Console.WriteLine, LogLevel.Information));
```

Log to the Console for specific events:

```C#
protected override void OnConfiguring(DbContextOptionsBuilder options)
    => options
	    .UseMyProvider("...")
		.LogTo(Console.WriteLine, new[] { CoreEventId.ContextInitialized, CoreEventId.ContextDisposed }));
```

Log to the Console for specific categories:

```C#
protected override void OnConfiguring(DbContextOptionsBuilder options)
    => options
	    .UseMyProvider("...")
		.LogTo(Console.WriteLine, new[] { DbLoggerCategory.Infrastructure.Name, DbLoggerCategory.Update.Name }));
```

Log to the Console with custom filter:

```C#
protected override void OnConfiguring(DbContextOptionsBuilder options)
    => options
	    .UseMyProvider("...")
		.LogTo(Console.WriteLine, (e, l) => e == CoreEventId.SaveChangesCompleted)));
```

Log to the Console for events in specific categories and a given level formatted as a single line using UTC timestamps:

```C#
protected override void OnConfiguring(DbContextOptionsBuilder options)
    => options
	    .UseMyProvider("...")
		.LogTo(
		    Console.WriteLine,
			new[] { DbLoggerCategory.Infrastructure.Name, DbLoggerCategory.Update.Name },
			LogLevel.Information,
			SimpleLoggerFormatOptions.SingleLine | SimpleLoggerFormatOptions.DefaultWithUtcTime | ));
```
ajcvickers added a commit that referenced this issue Nov 25, 2019
Fixes #16200
Fixes #1199

Examples:

Log to the Console:

```C#
protected override void OnConfiguring(DbContextOptionsBuilder options)
    => options
	    .UseMyProvider("...")
		.LogTo(Console.WriteLine);
```

Log to the Console for a given level:

```C#
protected override void OnConfiguring(DbContextOptionsBuilder options)
    => options
	    .UseMyProvider("...")
		.LogTo(Console.WriteLine, LogLevel.Information));
```

Log to the Console for specific events:

```C#
protected override void OnConfiguring(DbContextOptionsBuilder options)
    => options
	    .UseMyProvider("...")
		.LogTo(Console.WriteLine, new[] { CoreEventId.ContextInitialized, CoreEventId.ContextDisposed }));
```

Log to the Console for specific categories:

```C#
protected override void OnConfiguring(DbContextOptionsBuilder options)
    => options
	    .UseMyProvider("...")
		.LogTo(Console.WriteLine, new[] { DbLoggerCategory.Infrastructure.Name, DbLoggerCategory.Update.Name }));
```

Log to the Console with custom filter:

```C#
protected override void OnConfiguring(DbContextOptionsBuilder options)
    => options
	    .UseMyProvider("...")
		.LogTo(Console.WriteLine, (e, l) => e == CoreEventId.SaveChangesCompleted)));
```

Log to the Console for events in specific categories and a given level formatted as a single line using UTC timestamps:

```C#
protected override void OnConfiguring(DbContextOptionsBuilder options)
    => options
	    .UseMyProvider("...")
		.LogTo(
		    Console.WriteLine,
			new[] { DbLoggerCategory.Infrastructure.Name, DbLoggerCategory.Update.Name },
			LogLevel.Information,
			SimpleLoggerFormatOptions.SingleLine | SimpleLoggerFormatOptions.DefaultWithUtcTime | ));
```
ajcvickers added a commit that referenced this issue Nov 25, 2019
Fixes #16200
Fixes #1199

Examples:

Log to the Console:

```C#
protected override void OnConfiguring(DbContextOptionsBuilder options)
    => options
	    .UseMyProvider("...")
		.LogTo(Console.WriteLine);
```

Log to the Console for a given level:

```C#
protected override void OnConfiguring(DbContextOptionsBuilder options)
    => options
	    .UseMyProvider("...")
		.LogTo(Console.WriteLine, LogLevel.Information));
```

Log to the Console for specific events:

```C#
protected override void OnConfiguring(DbContextOptionsBuilder options)
    => options
	    .UseMyProvider("...")
		.LogTo(Console.WriteLine, new[] { CoreEventId.ContextInitialized, CoreEventId.ContextDisposed }));
```

Log to the Console for specific categories:

```C#
protected override void OnConfiguring(DbContextOptionsBuilder options)
    => options
	    .UseMyProvider("...")
		.LogTo(Console.WriteLine, new[] { DbLoggerCategory.Infrastructure.Name, DbLoggerCategory.Update.Name }));
```

Log to the Console with custom filter:

```C#
protected override void OnConfiguring(DbContextOptionsBuilder options)
    => options
	    .UseMyProvider("...")
		.LogTo(Console.WriteLine, (e, l) => e == CoreEventId.SaveChangesCompleted)));
```

Log to the Console for events in specific categories and a given level formatted as a single line using UTC timestamps:

```C#
protected override void OnConfiguring(DbContextOptionsBuilder options)
    => options
	    .UseMyProvider("...")
		.LogTo(
		    Console.WriteLine,
			new[] { DbLoggerCategory.Infrastructure.Name, DbLoggerCategory.Update.Name },
			LogLevel.Information,
			SimpleLoggerFormatOptions.SingleLine | SimpleLoggerFormatOptions.DefaultWithUtcTime | ));
```
ajcvickers added a commit that referenced this issue Nov 26, 2019
Fixes #16200
Fixes #1199

Examples:

Log to the Console:

```C#
protected override void OnConfiguring(DbContextOptionsBuilder options)
    => options
	    .UseMyProvider("...")
		.LogTo(Console.WriteLine);
```

Log to the Console for a given level:

```C#
protected override void OnConfiguring(DbContextOptionsBuilder options)
    => options
	    .UseMyProvider("...")
		.LogTo(Console.WriteLine, LogLevel.Information));
```

Log to the Console for specific events:

```C#
protected override void OnConfiguring(DbContextOptionsBuilder options)
    => options
	    .UseMyProvider("...")
		.LogTo(Console.WriteLine, new[] { CoreEventId.ContextInitialized, CoreEventId.ContextDisposed }));
```

Log to the Console for specific categories:

```C#
protected override void OnConfiguring(DbContextOptionsBuilder options)
    => options
	    .UseMyProvider("...")
		.LogTo(Console.WriteLine, new[] { DbLoggerCategory.Infrastructure.Name, DbLoggerCategory.Update.Name }));
```

Log to the Console with custom filter:

```C#
protected override void OnConfiguring(DbContextOptionsBuilder options)
    => options
	    .UseMyProvider("...")
		.LogTo(Console.WriteLine, (e, l) => e == CoreEventId.SaveChangesCompleted)));
```

Log to the Console for events in specific categories and a given level formatted as a single line using UTC timestamps:

```C#
protected override void OnConfiguring(DbContextOptionsBuilder options)
    => options
	    .UseMyProvider("...")
		.LogTo(
		    Console.WriteLine,
			new[] { DbLoggerCategory.Infrastructure.Name, DbLoggerCategory.Update.Name },
			LogLevel.Information,
			SimpleLoggerFormatOptions.SingleLine | SimpleLoggerFormatOptions.DefaultWithUtcTime | ));
```
@ajcvickers ajcvickers added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Dec 14, 2019
roji added a commit to roji/efcore.pg that referenced this issue Jan 25, 2020
See dotnet/efcore#16200
Follows 690ebc4540334c1d0938660a5960a25d4338acd4 in EF Core
roji added a commit to roji/efcore.pg that referenced this issue Jan 25, 2020
See dotnet/efcore#16200
Follows 690ebc4540334c1d0938660a5960a25d4338acd4 in EF Core
roji added a commit to roji/efcore.pg that referenced this issue Jan 28, 2020
See dotnet/efcore#16200
Follows 690ebc4540334c1d0938660a5960a25d4338acd4 in EF Core
roji added a commit to roji/efcore.pg that referenced this issue Jan 28, 2020
See dotnet/efcore#16200
Follows 690ebc4540334c1d0938660a5960a25d4338acd4 in EF Core
roji added a commit to roji/efcore.pg that referenced this issue Jan 28, 2020
See dotnet/efcore#16200
Follows 690ebc4540334c1d0938660a5960a25d4338acd4 in EF Core
roji added a commit to roji/efcore.pg that referenced this issue Jan 28, 2020
See dotnet/efcore#16200
Follows 690ebc4540334c1d0938660a5960a25d4338acd4 in EF Core
roji added a commit to roji/efcore.pg that referenced this issue Jan 29, 2020
See dotnet/efcore#16200
Follows 690ebc4540334c1d0938660a5960a25d4338acd4 in EF Core
@ajcvickers ajcvickers modified the milestones: 5.0.0, 5.0.0-preview1 Mar 13, 2020
@ajcvickers ajcvickers modified the milestones: 5.0.0-preview1, 5.0.0 Nov 7, 2020
@ajcvickers ajcvickers removed their assignment Sep 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant