public Startup(IHostingEnvironment env)
// Some other code
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Debug().WriteTo.File("YOUR FILE PATH HERE")
.CreateLogger();
}
在configure的方法中(这里使用serilog ):
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
loggerFactory.AddSerilog();