添加日志
This commit is contained in:
parent
72f84dce05
commit
d19afd6e8a
4
.gitignore
vendored
4
.gitignore
vendored
|
|
@ -360,4 +360,6 @@ MigrationBackup/
|
||||||
.ionide/
|
.ionide/
|
||||||
|
|
||||||
# Fody - auto-generated XML schema
|
# Fody - auto-generated XML schema
|
||||||
FodyWeavers.xsd
|
FodyWeavers.xsd
|
||||||
|
output/
|
||||||
|
logs/
|
||||||
|
|
@ -14,12 +14,14 @@ using HuanMeng.MiaoYu.Code.Cache;
|
||||||
using HuanMeng.MiaoYu.Code.Chat;
|
using HuanMeng.MiaoYu.Code.Chat;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
//Log.Logger = new LoggerConfiguration()
|
||||||
Log.Logger = new LoggerConfiguration()
|
// .WriteTo.Console()
|
||||||
.WriteTo.Console()
|
// .WriteTo.File("../output/logs/log-.txt", rollingInterval: RollingInterval.Day)
|
||||||
.WriteTo.File("logs/myapp.txt", rollingInterval: RollingInterval.Day)
|
// .CreateLogger();
|
||||||
.CreateLogger();
|
builder.Host.UseSerilog((context, services, configuration) => configuration
|
||||||
builder.Host.UseSerilog();
|
.ReadFrom.Configuration(context.Configuration)
|
||||||
|
.ReadFrom.Services(services)
|
||||||
|
.Enrich.FromLogContext());
|
||||||
// 检索程序集信息
|
// 检索程序集信息
|
||||||
AssemblyInfo assemblyInfo = AssemblyInfoHelper.GetAssemblyInfo();
|
AssemblyInfo assemblyInfo = AssemblyInfoHelper.GetAssemblyInfo();
|
||||||
// Add services to the container.
|
// Add services to the container.
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,27 @@
|
||||||
"Microsoft.AspNetCore": "Warning"
|
"Microsoft.AspNetCore": "Warning"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"Serilog": {
|
||||||
|
"Using": [ "Serilog.Sinks.Console", "Serilog.Sinks.File" ],
|
||||||
|
"MinimumLevel": {
|
||||||
|
"Default": "Information",
|
||||||
|
"Override": {
|
||||||
|
"Microsoft": "Warning",
|
||||||
|
"System": "Warning"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"WriteTo": [
|
||||||
|
{ "Name": "Console" },
|
||||||
|
{
|
||||||
|
"Name": "File",
|
||||||
|
"Args": {
|
||||||
|
"path": "../output/logs/log-.txt",
|
||||||
|
"rollingInterval": "Day"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId" ]
|
||||||
|
},
|
||||||
//腾讯云配置
|
//腾讯云配置
|
||||||
"TencentCloud": {
|
"TencentCloud": {
|
||||||
"SecretId": "AKIDLbhdP0Vs57yd7QZWu8A2jFbno8JKBUp6",
|
"SecretId": "AKIDLbhdP0Vs57yd7QZWu8A2jFbno8JKBUp6",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user