When you encounter problems in the development or production environment, we would like to see the log to troubleshoot the problem.
.MinimumLevel.Debug()
will set MinimumLevel
to Debug
to show more logs.
We don't want to see EF Core's
Debug
logs when your problem has nothing to do with EF Core.
var loggerConfiguration = new LoggerConfiguration()
.MinimumLevel.Debug()
.MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning)
.Enrich.FromLogContext()
.WriteTo.Async(c => c.File("Logs/logs.txt"))
If you have an EF Core-related problem, you can remove MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning)
and EnableSensitiveDataLogging
to see EF Core debug logs.
Configure<AbpDbContextOptions>(options =>
{
/* The main point to change your DBMS.
* See also BookStoreMigrationsDbContextFactory for EF Core tooling. */
options.UseSqlServer();
options.Configure(configureOptions =>
{
configureOptions.DbContextOptions.EnableSensitiveDataLogging();
});
});
If your API website experiences a JWT
authentication problem, please ShowPII
and output identity model
logs.
public async static Task<int> Main(string[] args)
{
IdentityModelEventSource.ShowPII = true;
IdentityModelEventSource.Logger.LogLevel = EventLevel.Verbose;
var wilsonTextLogger = new TextWriterEventListener("Logs/identitymodel.txt");
wilsonTextLogger.EnableEvents(IdentityModelEventSource.Logger, EventLevel.Verbose);
See: https://github.com/AzureAD/azure-activedirectory-identitymodel-extensions-for-dotnet/wiki/PII https://github.com/AzureAD/azure-activedirectory-identitymodel-extensions-for-dotnet/wiki/How-to-log-from-IdentityModelEventSource.Logger
If you have an OpenIddict
related problem, please override the OpenIddict
log level to Verbose
.
var loggerConfiguration = new LoggerConfiguration()
.MinimumLevel.Debug()
.MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning)
.MinimumLevel.Override("OpenIddict", LogEventLevel.Verbose)
.Enrich.FromLogContext()
.WriteTo.Async(c => c.File("Logs/logs.txt"))