Browse Source

[fix]启用数据库日志

master
贾荣国 2 years ago
parent
commit
6c4c8ee887
  1. 32
      WebApiService/src/Win_in.Sfs.Scp.WebApi.HttpApi.Host/Program.cs
  2. 4
      WebApiService/src/Win_in.Sfs.Scp.WebApi.HttpApi.Host/Win_in.Sfs.Scp.WebApi.HttpApi.Host.csproj

32
WebApiService/src/Win_in.Sfs.Scp.WebApi.HttpApi.Host/Program.cs

@ -16,22 +16,22 @@ namespace Win_in.Sfs.Scp.WebApi
.AddJsonFile("appsettings.json", false, true) .AddJsonFile("appsettings.json", false, true)
.Build(); .Build();
// Log.Logger = new LoggerConfiguration() Log.Logger = new LoggerConfiguration()
// .ReadFrom.Configuration(configuration) .ReadFrom.Configuration(configuration)
// .CreateLogger(); .CreateLogger();
//
Log.Logger = new LoggerConfiguration() // Log.Logger = new LoggerConfiguration()
#if DEBUG // #if DEBUG
.MinimumLevel.Debug() // .MinimumLevel.Debug()
#else // #else
.MinimumLevel.Information() // .MinimumLevel.Information()
#endif // #endif
.MinimumLevel.Override("Microsoft", LogEventLevel.Information) // .MinimumLevel.Override("Microsoft", LogEventLevel.Information)
.MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning) // .MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning)
.Enrich.FromLogContext() // .Enrich.FromLogContext()
.WriteTo.Async(c => c.File("Logs/logs.txt",rollingInterval:RollingInterval.Day)) // .WriteTo.Async(c => c.File("Logs/logs.txt",rollingInterval:RollingInterval.Day))
.WriteTo.Async(c => c.Console()) // .WriteTo.Async(c => c.Console())
.CreateLogger(); // .CreateLogger();
try try
{ {

4
WebApiService/src/Win_in.Sfs.Scp.WebApi.HttpApi.Host/Win_in.Sfs.Scp.WebApi.HttpApi.Host.csproj

@ -7,8 +7,8 @@
<RootNamespace>Win_in.Sfs.Scp.WebApi</RootNamespace> <RootNamespace>Win_in.Sfs.Scp.WebApi</RootNamespace>
<PreserveCompilationReferences>true</PreserveCompilationReferences> <PreserveCompilationReferences>true</PreserveCompilationReferences>
<UserSecretsId>Win_in.Sfs.Scp.WebApi-4681b4fd-151f-4221-84a4-929d86723e4c</UserSecretsId> <UserSecretsId>Win_in.Sfs.Scp.WebApi-4681b4fd-151f-4221-84a4-929d86723e4c</UserSecretsId>
<AssemblyVersion>1.22.0525.1</AssemblyVersion> <AssemblyVersion>1.22.0601.1</AssemblyVersion>
<FileVersion>1.22.0525.1</FileVersion> <FileVersion>1.22.0601.1</FileVersion>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

Loading…
Cancel
Save