0

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?

dev.doc
  • 569
  • 3
  • 12
  • 18

1 Answers1

0

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://learn.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

Doris Lv
  • 3,083
  • 1
  • 5
  • 14
  • Although I didn't quite understand why changing to "verbose" is require to capture TraceError - I tried it anyways. It doesn't seem to make a difference and there are still no log entries in the blob. Also, the screenshots you have don't seem to show the TraceError logged that we expect to see. – user2808659 Jul 27 '20 at 14:43