简体   繁体   中英

Azure WebJob not logging to blob storage

I have a dotnet core 1.1 web-api which uses ILogger to log to console. 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. 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.

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.

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:

Nuget packages:

在此处输入图片说明

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:

在此处输入图片说明

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM