我有一个运行.net core 2 app的Docker容器。
使用Program.cs
中的此代码配置日志记录
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.ConfigureLogging((hostingContext, logging) =>
{
logging.AddConfiguration(hostingContext.Configuration.GetSection("Logging"));
logging.AddConsole();
logging.AddDebug();
})
.UseStartup<Startup>();
和appsettings.json
文件
{
"Logging": {
"LogLevel": {
"Default": "Information"
}
},
}
记录似乎没问题,直接运行Kestrel时,我可以看到终端中的日志。同样的事情,当集装箱化时:命令docker logs
显示我想要的东西。
在Azure Web App中作为容器运行时,生产中会出现问题。我找不到任何一致的docker日志。
我试图通过FTP或通过url https://[mysite].scm.azurewebsites.net/api/logs/docker
访问日志文件,日志文件几乎是空的,例如,https://[mysite].scm.azurewebsites.net/api/vfs/LogFiles/2018_09_09_RD0003FF74F63E_docker.log
,只有容器起始行存在
此外,我在通常的门户界面中也有相同的行。
问题是:docker日志会自动输出到Azure Web App中的docker.log文件中吗?有什么东西我错过了吗?
您是否在容器设置中检查了日志?我按照this指南将容器部署到Azure Web应用程序。