Skip to content

How to enable logging of EF queries on console? #193

@SergejNe

Description

@SergejNe

How to enable logging for EF6 Statements?
I've tried everything, but it shows no queries.
Is it even possible with ExtCore?

e.g. https://erikej.github.io/efcore/2020/05/18/ef-core-simple-logging.html

How is it correct way?

Thanks

in Pomelo
optionsBuilder.LogTo(Console.WriteLine).UseMySql("Data So ....
...
public StorageContext(IOptions options) : base(options) { }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.EnableSensitiveDataLogging(true); <---------------------------------------
base.OnConfiguring(optionsBuilder);


in appsettings.json
"Serilog": {
"MinimumLevel": {
"Default": "Information",
"Override": {
"Microsoft": "Information",
"System": "Information",
"Microsoft.EntityFrameworkCore.Database.Command": "Information"
}
}
},

in Program.cs
.MinimumLevel.Override("Microsoft.EntityFrameworkCore", Serilog.Events.LogEventLevel.Information)

and and and ... other variants

Pomelo.EntityFrameworkCore.MySql" Version="6.0.1"
ExtCore.Data.EntityFramework" Version="7.0.0"
Serilog.AspNetCore" Version="3.4.0"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions