Azure ServiceBus Trigger Log Filtering

vincent219 256 Reputation points
2022-01-17T06:47:14.26+00:00

I'm using Azure Functions v3 with .NET.

HTTP communication occurs when certain Azure ServiceBus Triggers process messages.

The problem is, if logLevel is set to Information in host.json, when I record at Information level through the Logger received through FunctionContext.GetLogger("FunctionName"), even HTTP logs are output to the console window, making it difficult to distinguish them.

If I set logLevel to Warning as a trick, the HTTP log is not output because it is at the Information level, and I can record the log as Warning level through the Logger.

It is not an expedient like the above method, but I would like to record only the contents I record with the code as information and not record the other logs.

Is there any way to solve this?

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,909 questions
Developer technologies C#
0 comments No comments
{count} votes

Accepted answer
  1. MughundhanRaveendran-MSFT 12,506 Reputation points
    2022-01-17T13:25:36.39+00:00

    @vincent219 ,

    Thanks for reaching out to Q&A.

    From the loglevel perspective, we have multiple options but "information" is the closest that you can get to log the flow of your function. There are other configurations however they will either get removed or add more information which will add complexity

    Configure log levels: https://learn.microsoft.com/en-us/azure/azure-functions/configure-monitoring?tabs=v2#configure-log-levels

    The best approach is using Application insights where you can record only specific contents and set the sampling settings as mentioned in the following article.

    https://learn.microsoft.com/en-us/azure/azure-monitor/app/ilogger

    https://learn.microsoft.com/en-us/azure/azure-functions/configure-monitoring?tabs=v2#configure-sampling

    I hope this helps!

    Please 'Accept as answer' and ‘Upvote’ if it helped so that it can help others in the community looking for help on similar topics.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.