Azure Function-App 未记录到控制台或 AppInsights

Azure Function-App is not logging to console or AppInsights

我有一个带有 AzureFunctionVersion v3 的 Azure Function,现在有一段时间我没有在 Application Insights 或 Rider 控制台中看到任何未记录在 FunctionTrigger 本身中的日志。


[FunctionName("test")]
public IActionResult Test([HttpTrigger(AuthorizationLevel.Function, "delete", Route = BasePath + "/{roomId}")] HttpRequest req,
            ILogger log)
{
   log.LogInformation("Log is shown");

   myservice.DoIt();
}
namespace MyApp.Test.Service {
   public MyService(ILoggerFactory loggerFactory)
   {       
     _log = loggerFactory.CreateLogger(GetType().Namespace);
   }

   public void DoIt() {
      _log.LogInformation("Log is not shown");
   }
}

我的 host.json 看起来像:

"logging": {
        "applicationInsights": {
            "samplingExcludedTypes": "Request",
            "samplingSettings": {
                "isEnabled": false
            }
        },
        "logLevel": {
            "MyApp.*": "Information"
        }
    }

请尝试通过以下方式之一更改 logLevel

  1. "logLevel": {"MyApp": "Information"}

  2. "logLevel": { "Default": "Information" }