Browse Source

[fix]serilog设置调整到appsettings.json中

master
贾荣国 3 years ago
parent
commit
818c7a56cc
  1. 32
      WebApiService/src/Win_in.Sfs.Scp.WebApi.HttpApi.Host/Program.cs
  2. 44
      WebApiService/src/Win_in.Sfs.Scp.WebApi.HttpApi.Host/appsettings.json
  3. 2
      WebApiService/src/Win_in.Sfs.Scp.WebApi.HttpApi.Host/serilogsettings.Development.json
  4. 2
      WebApiService/src/Win_in.Sfs.Scp.WebApi.HttpApi.Host/serilogsettings.Production.Development.json
  5. 38
      WebApiService/src/Win_in.Sfs.Scp.WebApi.HttpApi.Host/serilogsettings.Production.json
  6. 2
      WebApiService/src/Win_in.Sfs.Scp.WebApi.HttpApi.Host/serilogsettings.Production.secrets.json
  7. 46
      WebApiService/src/Win_in.Sfs.Scp.WebApi.HttpApi.Host/serilogsettings.json
  8. 2
      WebApiService/src/Win_in.Sfs.Scp.WebApi.HttpApi.Host/serilogsettings.secrets.json

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

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

44
WebApiService/src/Win_in.Sfs.Scp.WebApi.HttpApi.Host/appsettings.json

@ -34,6 +34,50 @@
}
}
},
"Serilog": {
"Using": [ "Serilog.Sinks.File", "Serilog.Sinks.Async", "Serilog.Sinks.Console", "Serilog.Sinks.MSSqlServer" ],
"MinimumLevel": {
"Default": "Debug",
"Override": {
"Microsoft": "Information",
"Microsoft.EntityFrameworkCore": "Warning"
}
},
"WriteTo": [
{
"Name": "Async",
"Args": {
"configure": [
{
"Name": "File",
"Args": {
"path": "Logs\\log.txt",
"rollingInterval": "Day",
"restrictedToMinimumLevel": "Debug"
}
}
]
}
},
{
"Name": "Console",
"Args": {
"restrictedToMinimumLevel": "Debug",
"outputTemplate": "{Timestamp:HH:mm:ss.fff zzz} [{Level}] {Message} {NewLine}{Exception}"
}
},
{
"Name": "MSSqlServer",
"Args": {
"connectionString": "Server=127.0.0.1;Database=Scp_WebApi;User ID=sa;Password=Microsoft2008;connection timeout=600;",
"tableName": "AppLogs",
"autoCreateSqlTable": true
}
}
],
"Enrich": [ "FromLogContext", "WithMachineName", "WithProcessId", "WithThreadId" ]
},
"AsnOptions": {
"Active": true,
"PeriodSeconds": 10,

2
WebApiService/src/Win_in.Sfs.Scp.WebApi.HttpApi.Host/serilogsettings.Development.json

@ -1,2 +0,0 @@
{
}

2
WebApiService/src/Win_in.Sfs.Scp.WebApi.HttpApi.Host/serilogsettings.Production.Development.json

@ -1,2 +0,0 @@
{
}

38
WebApiService/src/Win_in.Sfs.Scp.WebApi.HttpApi.Host/serilogsettings.Production.json

@ -1,38 +0,0 @@
{
"App": {
"SelfUrl": "https://scp.iacchina.net:9988",
"CorsOrigins": "https://scp.iacchina.net:9977,https://scp.iacchina.net:9988,https://localhost:9977,https://localhost:9988",
"RedirectAllowedUrls": "https://scp.iacchina.net:9977,https://scp.iacchina.net:9988"
},
"ConnectionStrings": {
"Default": "Server=127.0.0.1,13314;Database=Scp_WebApi;User ID=superadmin;Password=Microsoft@2021;connection timeout=600;",
"WebApi": "Server=127.0.0.1,13314;Database=Scp_WebApi;User ID=superadmin;Password=Microsoft@2021;connection timeout=600;",
"V1Scp": "Server=127.0.0.1£º13314;Database=Scp_AC;User ID=sa;Password=Microsoft2008;connection timeout=600;"
},
"AuthServer": {
"Authority": "https://scp.iacchina.net:9988",
"RequireHttpsMetadata": "false",
"SwaggerClientId": "WebApi_Swagger",
"SwaggerClientSecret": "1q2w3e*"
},
"IdentityServer": {
"Clients": {
"WebApi_Web": {
"ClientId": "WebApi_Web",
"ClientSecret": "1q2w3e*",
"RootUrl": "https://scp.iacchina.net:9988"
},
"WebApi_App": {
"ClientId": "WebApi_App",
"ClientSecret": "1q2w3e*",
"RootUrl": "https://scp.iacchina.net:9988"
},
"WebApi_Swagger": {
"ClientId": "WebApi_Swagger",
"ClientSecret": "1q2w3e*",
"RootUrl": "https://scp.iacchina.net:9988"
}
}
},
"AlwaysAllowAuthorization": false
}

2
WebApiService/src/Win_in.Sfs.Scp.WebApi.HttpApi.Host/serilogsettings.Production.secrets.json

@ -1,2 +0,0 @@
{
}

46
WebApiService/src/Win_in.Sfs.Scp.WebApi.HttpApi.Host/serilogsettings.json

@ -1,46 +0,0 @@
{
"Serilog": {
"Using": [ "Serilog.Sinks.File", "Serilog.Sinks.Async", "Serilog.Sinks.Console", "Serilog.Sinks.MSSqlServer" ],
"MinimumLevel": {
"Default": "Debug",
"Override": {
"Microsoft": "Information",
"Microsoft.EntityFrameworkCore": "Warning"
}
},
"WriteTo": [
{
"Name": "Async",
"Args": {
"configure": [
{
"Name": "File",
"Args": {
"path": "Logs\\log.txt",
"rollingInterval": "Day",
"restrictedToMinimumLevel": "Debug"
}
}
]
}
},
{
"Name": "Console",
"Args": {
"restrictedToMinimumLevel": "Debug",
"outputTemplate": "{Timestamp:HH:mm:ss.fff zzz} [{Level}] {Message} {NewLine}{Exception}"
}
},
{
"Name": "MSSqlServer",
"Args": {
"connectionString": "Server=127.0.0.1;Database=Scp_WebApi;User ID=sa;Password=Microsoft2008;connection timeout=600;",
"tableName": "AppLogs",
"autoCreateSqlTable": true
}
}
],
"Enrich": [ "FromLogContext", "WithMachineName", "WithProcessId", "WithThreadId" ]
}
}

2
WebApiService/src/Win_in.Sfs.Scp.WebApi.HttpApi.Host/serilogsettings.secrets.json

@ -1,2 +0,0 @@
{
}
Loading…
Cancel
Save