Search code examples
azureazure-webjobsazure-webjobssdkazure-storage-queueswebjob

WebJob - supress logs for Azure Queue connection


After upgrading my WebJobs to dotnet 7 everything is working pretty fine, but now it shows logs for connecting to Queues like this:

enter image description here

This is being shown everytime the job checks for new messages (5 sec). After this, it's impossible to check on the logs that I really need.

How can I hide these logs and see just the ones I really need?

Thanks in advance.


Solution

  • Initially even I got the same logs with all the Requests from Azure.Core package.

     Azure.Core[1]
          Request [****] GET https://harshu**.queue.core.windows.net/queue/messages?numofmessages=16&visibilitytimeout=600
          x-ms-version:2018-11-09
          Accept:application/xml
          x-ms-client-request-id:****
       --------
    
    • The reason for this is configuring the logging in Program.cs file to add all the console logs.
     builder.ConfigureLogging((context, log) =>
     {
         log.AddConsole();
     }
    
    • To avoid this, you can add the logging level in appsettings.json file to ignore the logs from Azure.Core package.

    I have taken references from this SOThread configuration.

    With Configuration Logging level in appsettings.json file:

    appsettings.json file:

    {
      "Logging": {
        "LogLevel": {
          "Default": "Information",
          "Azure.Core": "None"
        }
      },
      "AzureWebJobsStorage": "DefaultEndpointsProtocol=https;AccountName=harshu**;AccountKey=*****;EndpointSuffix=core.windows.net"
    }
    

    Program.cs file

      builder.ConfigureLogging((context, log) =>
      {    
          var logconfig = context.Configuration.GetSection("Logging");
          log.AddConfiguration(logconfig); 
          log.AddConsole();
      });
    

    OR

    With AddFilter option:

    Can add a filter in program.cs file itself.

      builder.ConfigureLogging((context, log) =>
      {           
          log.AddConsole();
          log.AddFilter("Azure.Core", LogLevel.None);
      });
    

    Output: enter image description here