microsoft / InventorySample

Sample UWP application for LOB scenarios
MIT License
591 stars 199 forks source link

Help adding Logging.EventLog based on ILogger #62

Open KevHoff2020 opened 4 years ago

KevHoff2020 commented 4 years ago

Hi,

I'm new to EF, and I see that it supports logging the SQL queries in EF Core 2.0, so I was trying to add Microsoft.Extensions.Logging.EventLog, but when I install version 2.0.1 (hoping this would be compatible).

The build output shows: Severity Code Description Project File Line Suppression State Warning NU1701 Package 'Microsoft.Extensions.Logging.EventLog 2.0.1' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework 'UAP,Version=v10.0.16299'. This package may not be fully compatible with your project. Inventory.App C:\Users\Owner\Documents\HAIB\Samples\InventorySample-master-dblogger\src\Inventory.App\Inventory.App.csproj 1

Now trying to add the recommended way of creating the logger, the LoggerFactory.Create method is not available.

using Microsoft.Extensions.Logging;

public class DbLogger
{
    public static readonly ILoggerFactory Factory
        = LoggerFactory.Create(builder =>
        {
            builder
                .AddFilter(DbLoggerCategory.Name, LogLevel.Debug)
                .AddEventLog()
                ;
        });
}

Having a DbLogger in this way would be extremely useful so you can see the internal workings of EF core.

Any help would be appreciated. -Kevin