0
votes

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?

1

1 Answers

5
votes

According to your description, I created my console application with the target framework .NET Core 1.1 via VS2017 as follows:

Nuget packages:

enter image description here

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:

enter image description here

enter image description here