Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Appinsights logging for different environments #2576

Closed
andesk10 opened this issue Sep 29, 2022 · 4 comments · Fixed by #2581
Closed

Appinsights logging for different environments #2576

andesk10 opened this issue Sep 29, 2022 · 4 comments · Fixed by #2581

Comments

@andesk10
Copy link

Azure app insights is working in the way shown below.

Added these two dependencies:

  1. implementation("com.microsoft.azure:applicationinsights-agent:3.4.1")
  2. implementation("com.microsoft.azure:applicationinsights-runtime-attach:3.4.1")

Invoked the attach() method as mentioned in docs
@SpringBootApplication
public class SpringBootApp {

public static void main(String[] args) {
ApplicationInsights.attach();
SpringApplication.run(SpringBootApp.class, args);
}
}

I have created applicationinsight.json, added my connection string and placed in src/main/resources.

However, my need is to log local and dev logs to one connection string (resource group) and prod logs to another connection string (resource group).
I have tried creating a new file applicationinsight-local.json, applicationinsight-dev.json in same path. But, that doesnt seem to work.
Dont you offer this functionality.

Thanks.

@ghost ghost added the Needs: Triage 🔍 label Sep 29, 2022
@heyams
Copy link
Contributor

heyams commented Sep 29, 2022

we don't support applicationinsights-local.json nor applicationinsights-dev.json.
can you check out connection string overrides?

@trask
Copy link
Member

trask commented Sep 29, 2022

I could see supporting custom classpath location for applicationinsights.json, maybe runtime attach could try resolving APPLICATIONINSIGHTS_CONFIGURATION_FILE against the classpath first, and then fall back to resolving it against the file system

@trask
Copy link
Member

trask commented Sep 29, 2022

btw @andesk10

implementation("com.microsoft.azure:applicationinsights-agent:3.4.1")

you shouldn't add an implementation dependency on the agent, the runtime-attach artifact bundles it internally (not as a transitive dependency)

@jeanbisutti
Copy link
Member

I could see supporting custom classpath location for applicationinsights.json, maybe runtime attach could try resolving APPLICATIONINSIGHTS_CONFIGURATION_FILE against the classpath first, and then fall back to resolving it against the file system

This would not work when the applicationinsight.json file (applicationinsight-local.json, applicationinsight-dev.json, ...) is included into a Spring Boot jar file. So, I would suggest providing a system property overriding the default name of the applicationinsight.json when the json file is retrieved from the classpath. This solution would fit well with Spring Boot profile configuration via system property (-Dspring.profiles.active=dev).

@jeanbisutti jeanbisutti self-assigned this Oct 3, 2022
trask added a commit that referenced this issue Oct 12, 2022
…ttachment (#2581)

Fix #2576

Co-authored-by: Trask Stalnaker <trask.stalnaker@gmail.com>
@ghost ghost added the Status: Fixed label Oct 12, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Nov 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
4 participants