Я решаю проблему.
В Startup.cs :
public class Startup
{
string LogFilePath;
public Startup(IHostingEnvironment env)
{
// location of the logs
var exePath = Assembly.GetEntryAssembly().Location.ToString();
var directoryPath = Path.GetDirectoryName(exePath);
LogFilePath = Path.Combine(directoryPath + "\\logs\\"); // you can replace "logs" by an other folder name
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env,ILoggerFactory loggerFactory)
{
loggerFactory.AddDebug();
loggerFactory.AddFile(LogFilePath + "api-{Date}.txt",LogLevel.Debug,null,false,null,30); // you can replace "api" by an other file name for your log
}
}
В Program.cs :
public class Program
{
public static void Main(string[] args)
{
CreateWebHostBuilder(args).Build().Run();
}
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseKestrel()
.UseIISIntegration()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseStartup<Startup>();
}