- Azure subscription
- Basic knowledge of Azure cloud shell
- Deployed Azure webapp hosted on a linux app service plan
- Application insight instance linked to the web app
- A spring mvc app
Reuse the POM.xml file as is for all dependecies. Make sure to change the resource names mentioned under the "azure-webapp-maven-plugin"
Logging DEBUG, INFO and ERROR events for a Linux based Java Azure WebApp/API using application insights
Navigate to controller class
Download the latest version of the applicationinsights-agent-X.X.X.jar and publish the jar inside the wwwroot folder of your Azure WebApp
- Add AI-Agent.xml. More info here
- Add application.properties. More info here
- Add log4j2.xml. This appends log4j events to ApplicationInsights 'traces' table.
- Open the Azure cloud shell and use the below cli command
az webapp config appsettings set -g resroucegroupname -n uniqueappname --settings 'JAVA_OPTS=-javaagent:/home/site/wwwroot/applicationinsights-agent-X.X.X.jar'