How to see logs written using Console.WriteLine() in an azure function (in process) in azure portal?

Varkeychan Jacob 25 Reputation points
2024-01-24T05:01:09.9133333+00:00

I have an azure function (in process runtime) and I'd like to print some logs using Console.WriteLine(). I can see these logs when run locally, but how to see them in the azure portal?

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,925 questions
{count} votes

Accepted answer
  1. MuthuKumaranMurugaachari-MSFT 22,441 Reputation points Moderator
    2024-01-24T17:20:15.01+00:00

    Varkeychan Jacob Thanks for posting your question in Microsoft Q&A. As described in doc: Logging, Console.Write doesn't get captured in App Insights/Log Stream. The suggested way is to use ILogger dependency injection to write the logs like below: User's image

    With ILogger, the logs are logged into App Insights, and we can be viewed via Monitor Tab or Log Stream and make sure you have set log levels. I saw you posted this question in https://github.com/Azure/azure-functions-host/issues/9828 (similar discussion in reddit) and if you face any issues in using ILogger, let me know with the details.

    I hope this helps and feel free to reach out for any questions.


    If you found the answer to your question helpful, please take a moment to mark it as Yes for others to benefit from your experience. Or simply add a comment tagging me and would be happy to answer your questions.

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Vahid Ghafarpour 23,385 Reputation points Volunteer Moderator
    2024-01-24T05:07:25.3+00:00

    Thanks for posting your question in the Microsoft Q&A forum. To view the logs your Azure Function generates, you can use the Log Stream feature in the Azure portal. https://learn.microsoft.com/en-us/azure/container-apps/log-streaming?tabs=bash ** Please don't forget to close up the thread here by upvoting and accept it as an answer if it is 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.