[英]Azure WebJob not logging to blob storage
I have a dotnet core 1.1 web-api which uses ILogger to log to console. 我有一个dotnet核心1.1 web-api,它使用ILogger记录到控制台。 These logs are picked up and sent to blobs based on (appname)/month/day/hour if I turn on Application Logging (Blob) option under Monitoring/Diagnostic Logs in the azure console.
如果我在azure控制台中的“监视/诊断日志”下打开了“应用程序日志记录”选项,则这些日志将根据(appname)/月/日/小时被提取并发送到blob。 This works out pretty well.
这样效果很好。
However, my webjob which uses the same ILogger and the same config does not have its output go to these mm/dd/hh directories. 但是,使用相同ILogger和相同配置的我的webjob没有输出到这些mm / dd / hh目录。
If I turn on Application Logging (Filesystem) I see my logs, but I would really like them to go to the same blob storage location, so I can pick them up in Splunk. 如果打开应用程序日志记录(文件系统),则可以看到日志,但是我真的希望它们进入相同的Blob存储位置,因此可以在Splunk中进行提取。
Where am I going wrong? 我要去哪里错了?
According to your description, I created my console application with the target framework .NET Core 1.1 via VS2017 as follows: 根据您的描述,我通过VS2017使用目标框架.NET Core 1.1创建了控制台应用程序,如下所示:
Nuget packages: Nuget软件包:
Program.cs Program.cs
class Program
{
static void Main(string[] args)
{
ILoggerFactory loggerFactory = new LoggerFactory()
.AddConsole()
.AddDebug()
.AddAzureWebAppDiagnostics();
ILogger<Program> logger = loggerFactory.CreateLogger<Program>();
logger.LogInformation("Hello World!");
logger.LogInformation("Sleeping for 5s before exit...");
Thread.Sleep(5 * 1000);
}
}
After deployed to azure, I could see the logs under KUDU console and the blob log file as follows: 部署到天蓝色后,我可以在KUDU控制台下看到日志和blob日志文件,如下所示:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.