0
votes

I've configured app service logging for the app service to go to an azure blob storage.

My test code for the manually-triggered, .net core, test webjob is simple:

namespace TestWebJob
{
    class Program
    {
        static void Main(string[] args)
        {
            System.Diagnostics.Trace.TraceError("message using diagnostics");
        }
    }
}

I would expect to see the Trace logged to the storage blob; but instead my blob is empty after the job runs.

What am I doing wrong here?

1
you should use ILogger rather than Trace.TraceErrorThiago Custodio
Any more details or examples on implementation?user2808659

1 Answers

0
votes

Update......

Sorry for the last answer. I get your point now.

The reason is that we didn't have a TraceListener in our code.

You could add this in your code:

Trace.Listeners.Add(new ConsoleTraceListener());

I found it from the second answer here: Azure WebJobs: Can't find Trace logging.

If it didn't work, check your runtime. You can see it is different adding logs in .NET or .NET Core from this article: https://docs.microsoft.com/en-us/azure/app-service/troubleshoot-diagnostic-logs#add-log-messages-in-code

enter image description here

--------------------------------------------------------Dividing line-------------------------------------------------------

I tried to deploy a WebJob using your code, and I found that maybe you should change the log's level in app service log settings to Verbose: enter image description here

You can see the details in different log's level in this page: enter image description here

When I set the logs level to Information and run the WebJob, there is nothing added in my blob. enter image description here

After I change the logs level to Verbose and run the WebJob, there are the information added. enter image description here