添加日志
This commit is contained in:
parent
72f84dce05
commit
d19afd6e8a
4
.gitignore
vendored
4
.gitignore
vendored
|
|
@ -360,4 +360,6 @@ MigrationBackup/
|
|||
.ionide/
|
||||
|
||||
# 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 Serilog;
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
Log.Logger = new LoggerConfiguration()
|
||||
.WriteTo.Console()
|
||||
.WriteTo.File("logs/myapp.txt", rollingInterval: RollingInterval.Day)
|
||||
.CreateLogger();
|
||||
builder.Host.UseSerilog();
|
||||
//Log.Logger = new LoggerConfiguration()
|
||||
// .WriteTo.Console()
|
||||
// .WriteTo.File("../output/logs/log-.txt", rollingInterval: RollingInterval.Day)
|
||||
// .CreateLogger();
|
||||
builder.Host.UseSerilog((context, services, configuration) => configuration
|
||||
.ReadFrom.Configuration(context.Configuration)
|
||||
.ReadFrom.Services(services)
|
||||
.Enrich.FromLogContext());
|
||||
// 检索程序集信息
|
||||
AssemblyInfo assemblyInfo = AssemblyInfoHelper.GetAssemblyInfo();
|
||||
// Add services to the container.
|
||||
|
|
|
|||
|
|
@ -8,6 +8,27 @@
|
|||
"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": {
|
||||
"SecretId": "AKIDLbhdP0Vs57yd7QZWu8A2jFbno8JKBUp6",
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user