Azure Functions file system logging (Linux/Java8)

Zarick 26 Reputation points
2021-08-11T15:44:53.647+00:00

I'm struggling with file system based logging on Azure Functions.

The current work is based on Linux/Java1.8. The function I'm working on is trivial (after all, lots of interesting functionality is not available for Java).

However whenever try to resolve some integration issues (eg: Blob Trigger, or Queue Trigger), the developer experience is unpleasant which I think is largely due to the lack / confusing docs around logging.

I understand there is Application Insights and Local Emulator mode. But my question here is mainly about file system logging (ie the logging I can see from the SSH session either via az webapp create-remote-connection or Kudu web SSH).

The reason for me to completely understand the file system logging is twofold.

  1. When troubleshooting integration problem (for example, blob trigger does not fire as expected, or the function keep crashing), using App Insight is not a good approach (it constantly have few minutes delay), and using local mode (functions core tools) does not fits as well as the problem is largely related to the integration setup on a real deployment.
  2. I'm working in a highly regulated environment, we have serious to control where (and how) the log is stored.

Hence, can someone help with the below questions?

  1. I'm using App Service Plan (P1V3, if it matters). Where does the log file actually store, I read something that the logs (/home/LogFiles) is mounted from Azure Files. But I do not see which storage account is actually used for this purpose.
  2. Does the file system logs (/home/LogFiles) rotated? What is the rotation logic? How long will it keep and how to change the rotation rules?
  3. For some logging messages, I can see it appears in a few different log files. What is the exact logic of this arrangement?
    • /home/LogFiles/__datetime__hostname__default_docker.log
    • /home/LogFiles/__datetime__hostname__docker.log
    • /home/LogFiles/Application/Functions/Host/*.log
    • /home/LogFiles/Application/Functions/Function/FuncName/*.log
    • /var/log/functionslogs/functionslogsv2.log
  4. Can I disable all file system logging (which I would like to do it for production) or can I specific all file system logging send to Azure Blob storage (AzureWebJobStorage or something similar).
  5. On Portal, there is a page labelled "App Service Logging", where I can switch on 'Application Logging' to 'filesystem' (defaults to OFF). What exactly does this switch work under the cover? Before I switch it on, I can see Host messages appear under /home/LogFiles/Application/Functions/Host/log After I switch it on, those Host messages also appear on /home/LogFiles/_default_docker.log If I verify the config with az webapp log show, this action actually switches on http logging (but not application logging).

Long post, thanks in advance.

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

1 answer

Sort by: Most helpful
  1. MughundhanRaveendran-MSFT 12,506 Reputation points
    2021-10-04T07:13:23.223+00:00

    @Zarick-5916 ,

    Here are the answers to your questions:

    1) I'm using App Service Plan (P1V3, if it matters). Where does the log file actually store, I read something that the logs (/home/LogFiles) is mounted from Azure Files. But I do not see which storage account is actually used for this purpose.

    Ans: Yes, Azure functions running on a dedicated app service plan (P1v3) would use Azure Files storage as its File system storage. This is a part of Azure Functions Paas internal architecture and it is not exposed to customers. They are exposed as a folder structure accessible via the Kudu site, for Linux apps, you can SSH into the container and access the log files

    2) Does the file system logs (/home/LogFiles) rotated? What is the rotation logic? How long will it keep and how to change the rotation rules?

    Ans: There is no rotation logic. There are multiple log files available under the /home/LogFiles directory (Application logs, web server logs etc), retention period would vary accordingly. For application logging, you can specify the retention period : https://learn.microsoft.com/en-us/azure/app-service/troubleshoot-diagnostic-logs#enable-application-logging-linuxcontainer

    3) For some logging messages, I can see it appears in a few different log files. What is the exact logic of this arrangement?

    Ans : Please refer the below article which talks about different log files
    https://learn.microsoft.com/en-us/azure/app-service/troubleshoot-diagnostic-logs#access-log-files

    4) Can I disable all file system logging (which I would like to do it for production) or can I specific all file system logging send to Azure Blob storage (AzureWebJobStorage or something similar).

    Ans: By setting “fileLoggingMode” property to “never” in Host.json, the logging can be disabled or by also turning off the App service logs in the portal which you have mentioned below. Unfortunately, sending it to blob storage is only available on windows based Function apps.
    https://learn.microsoft.com/en-us/azure/azure-functions/functions-host-json#logging

    5) On Portal, there is a page labelled "App Service Logging", where I can switch on 'Application Logging' to 'filesystem' (defaults to OFF).

    Ans: This logs refer to application logging mentioned in the Answer (2)

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


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.