Skip to content

Commit 9625385

Browse files
authored
Merge pull request #212508 from trask/spring-yaml
Spring Boot updates
2 parents d0f726a + 0db2580 commit 9625385

File tree

1 file changed

+34
-14
lines changed

1 file changed

+34
-14
lines changed

articles/azure-monitor/app/java-spring-boot.md

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,11 @@ ms.devlang: java
77
ms.custom: devx-track-java
88
---
99

10-
# Configure Azure Monitor Application Insights for Spring Boot
10+
# Using Azure Monitor Application Insights with Spring Boot
1111

12-
You can enable the Azure Monitor Application Insights agent for Java by adding an argument to the JVM. When you can't do this, you can use a programmatic configuration. We detail these two configurations below.
12+
There are two options for enabling Application Insights Java with Spring Boot: JVM argument and programmatically.
1313

14-
## Addition of a JVM argument
15-
16-
### Usual case
14+
## Enabling with JVM argument
1715

1816
Add the JVM arg `-javaagent:"path/to/applicationinsights-agent-3.4.1.jar"` somewhere before `-jar`, for example:
1917

@@ -35,9 +33,14 @@ If you're using the *shell* form, add the JVM arg `-javaagent:"path/to/applicati
3533
ENTRYPOINT java -javaagent:"path/to/applicationinsights-agent-3.4.1.jar" -jar <myapp.jar>
3634
```
3735

38-
## Programmatic configuration
36+
### Configuration
37+
38+
See [configuration options](./java-standalone-config.md).
39+
40+
## Enabling programmatically
41+
42+
To enable Application Insights Java programmatically, you must add the following dependency:
3943

40-
To use the programmatic configuration and attach the Application Insights agent for Java during the application startup, you must add the following dependency.
4144
```xml
4245
<dependency>
4346
<groupId>com.microsoft.azure</groupId>
@@ -46,7 +49,8 @@ To use the programmatic configuration and attach the Application Insights agent
4649
</dependency>
4750
```
4851

49-
And invoke the `attach()` method of the `com.microsoft.applicationinsights.attach.ApplicationInsights` class.
52+
And invoke the `attach()` method of the `com.microsoft.applicationinsights.attach.ApplicationInsights` class
53+
in the first line of your `main()` method.
5054

5155
> [!WARNING]
5256
>
@@ -58,7 +62,7 @@ And invoke the `attach()` method of the `com.microsoft.applicationinsights.attac
5862
5963
> [!WARNING]
6064
>
61-
> The invocation must be requested at the beginning of the `main` method.
65+
> The invocation must be at the beginning of the `main` method.
6266
6367
Example:
6468

@@ -73,10 +77,26 @@ public class SpringBootApp {
7377
}
7478
```
7579

76-
If you want to use a JSON configuration:
77-
* The `applicationinsights.json` file has to be in the classpath
78-
* Or you can use an environmental variable or a system property, more in the _Configuration file path_ part on [this page](../app/java-standalone-config.md). Spring properties defined in a Spring _.properties_ file are not supported.
80+
### Configuration
81+
82+
> [!NOTE]
83+
> Spring's `application.properties` or `application.yaml` files are not supported as
84+
> as sources for Application Insights Java configuration.
85+
86+
Programmatic enablement supports all the same [configuration options](./java-standalone-config.md)
87+
as the JVM argument enablement, with the following differences below.
88+
89+
#### Configuration file location
90+
91+
By default, when enabling Application Insights Java programmatically, the configuration file `applicationinsights.json`
92+
will be read from the classpath.
93+
94+
See [configuration file path configuration options](./java-standalone-config.md#configuration-file-path)
95+
to change this location.
96+
97+
#### Self-diagnostic log file location
7998

99+
By default, when enabling Application Insights Java programmatically, the `applicationinsights.log` file containing
100+
the agent logs will be located in the directory from where the JVM is launched (user directory).
80101

81-
> [!TIP]
82-
> With a programmatic configuration, the `applicationinsights.log` file containing the agent logs is located in the directory from where the JVM is launched (user directory). This default behavior can be changed (see the _Self-diagnostics_ part of [this page](../app/java-standalone-config.md)).
102+
See [self-diagnostic configuration options](./java-standalone-config.md#self-diagnostics) to change this location.

0 commit comments

Comments
 (0)