Correlation Id[Trace.Id] in logs coming with self-attach API JAVA APM Agent Setup way but not coming with manual -javaagent flag way

I have Springboot application. I want to configure log correlation with APM. I have specfied %X{trace.id} in Log pattern to get correlation Id.

I tried to setup with APM setup Manual setup with -javaagent flag then I am getting %X{trace.id} as blank.

java -javaagent:elastic-apm-agent-1.18.0.RC1.jar -jar -Delastic.apm.service_name=TEST-SERVICE -Delastic.apm.server_urls=http://192.168.0.11:8200 -Denvironment=Development -Dprofiling_inferred_spans_enabled=true -Denable_log_correlation=true target/test-0.0.1-SNAPSHOT.jar

Then I thought to setup Programmatic API setup to self-attach then I am getting %X{trace.id}.

java -jar target/test-0.0.1-SNAPSHOT.jar

Please help me with this behaviour as I don't want to keep elastic-apm dependency in code and want to go with -javaagent way.

Hi,

Have you already enabled log correlation as this is off by default?

Best regards
Wolfram

Yes @Wolfram_Haussig , I have enabled log correlation in -javaagent way using below passed variable.

-Denable_log_correlation=true

Thus, if I understand correctly, you get the proper log correlation working when using the programmatic self-attach but not when using -javaagent option ?

It seems that you forgot the co.elastic.apm prefix for the following configuration options: environment, profiling_inferred_spans_enabled and enable_log_correlation

You can check the configuration read by the agent by setting log_level=debug, this will output what configuration is applied by the agent at agent startup. With that, you should be able to see that the options without the prefix listed above are just ignored.

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.