Test function on Linux consumption plan that just logs the HTTP request headers:
public async Task<IActionResult> Run(
[HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = null)] HttpRequest req,
ILogger log)
{
log.LogInformation("C# HTTP trigger function processed a request.");
log.LogInformation("Request headers:");
foreach (var header in req.Headers)
{
log.LogInformation($"{header.Key} : {header.Value}");
}
...
}
This is what the Application Insights log stream shows in real time:
2021-03-30T19:09:19Z [Information] C# HTTP trigger function processed a request.
2021-03-30T19:09:19Z [Information] Request headers:
As you can see, it showed the "Request headers:" entry, but the logged entries in the foreach loop do not show.
However, if I review the actual logs in application insights, they do contain the logged header entries.
But the point of the "log stream" is to show these things in near real time for convenient debugging. The actual transaction logs can lag by minutes.
Additionally, sometimes the logs do show up in the log stream (random), but oftentimes they don't. This function is not even in production so there is little to no traffic.
Is this just a performance limitation of the log stream? Is there a better way to go around this? I know I can debug functions locally, but the real requests have to hit the real function. Also since I prefer the Linux consumption plan, the "file system" log stream is not available.