@M. Vaihinger , Thank you for your question.
I understand that you are trying to collect logs from your application to Log Analytics workspace. However, I was not sure of how you have deployed the app service. I am providing information on the 2 main ways through which the application can be hosted and related steps required to collect the custom logs.
Hosted on Azure App Service - this is fully managed platform for hosting App. In this scenario you don't get access to the underlying VM and Azure maintains it for you. To collect custom logs from this type of app deployment, you can
- Enable Diagnostic settings for the App Service to forward custom logs to a Log Analytics workspace.
- Enable Application Insights and use ILogger based logging to send logs to AppInsights/LA worksapce directly (without enabling the diagnostic settings.)
Note that, with this kind of hosting, the Log Analytics Agent Or Azure Monitor agent do not come in picture, as they are used for collecting information from Virtual machines (which is platform managed in this case).
Hosted on VM - You can also host Application on Azure VM where you would have full control of VM. In this case you can use Azure Monitor agent (the legacy - Log Analytics Agent OR the new - Azure Monitor Agent). In this case also, you have the following options for collection of logs:
- Enable Application Insights and use ILogger based logging to send logs to AppInsights/LA worksapce directly - similar to app service monitoring. The same mechanism can also be used here where the AppInsights is enabled for the application hosted on VM and custom logs can be sent to AppInsights (which uses LA workspace for storing the logs)
- If there are logs which are in custom location (outside the framework based logging, for example text written to custom file path), you can use the Azure Monitor Agent to collect logs from such file. I would advise using the latest Azure Monitor Agent to collect logs from these files. For details, see Collect text logs with Azure Monitor Agent
Hope this helps.
If the answer did not help, please add more context/follow-up question for it, and we will help you out. Else, if the answer helped, please click Accept answer so that it can help others in the community looking for help on similar topics.