我已经在program.cs
中进行了配置,并安装了所有软件包,但无法正常工作。
var configuration = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json")
.Build();
Log.Logger = new LoggerConfiguration()
.ReadFrom.Configuration(configuration)
.WriteTo
.Map("0", "Other-Other", (name, wt) => wt.File($"C:\\Serilog\\{name.Split('-')[0]}\\{name.Split('-')[1]}.txt", rollingInterval: RollingInterval.Day))
.CreateLogger();
我使用的日志行-
logger.LogInformation("\n Start InsertPRAsync Method.");
答案 0 :(得分:0)
尝试在.UseSerilog()
方法中将CreateDefaultBuilder()
添加到CreateHostBuilder()
,如下所示:
来自Serilog.AspNetCore Documentation
的示例Host.CreateDefaultBuilder(args)
.UseSerilog() // <-- Add this line
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});