Trace.id and transaction.id not being added to log entry

Good evening everyone,

I was able to set up the APM Java Agent and activated the log_correlation option without further issues.

Next, I got the tool to log into a file by using the ECS Java Logging tool and its standard settings for log4j (configure a file and log appender and add those to the rootLogger).

My Java tool is able to execute Groovy Scripts, which can be configured on runtime. As the Groovy framework has not been implemented yet, I added a monitored method to the APM Java Agent org.groovyrunner.AbstracScript#runScript, so now I am able to see the span from within APM.

Now I’d like to see any log entries generated within this span. For this, I instantiate a Logger within my Groovy code and log an info message. Right after, I see how the entry gets sent to Elasticsearch but the fields trace.id and transaction.id are nowhere to be found.

Is there anything else I can do on my side to get this running? I have no possibility to modify the source code of the Java app or Groovy library. I can only edit the Scripts and change the configuration of the Elastic Stack.

I’d appreciate any hints and I can also provide configuration files upon request.

Thanks,
Pablo

P.S. in case you wonder the Java app is Jira and the Groovy tool is called ScriptRunner for Jira.

Hi @pculebras and welcome to our forum!

We just merged a bug fix yesterday that prevented log correlation from working when log4j2 is used without slf4j. We currently have hard time deploying a daily snapshot, but if you are quick enough, you can download the latest master build artefact and try it out.

Please let us know if that solved the issue.

Did this bug also affect log4j (without the 2)?

No... What exact version are you using?

Try setting log_level to debug and see if logs provide any hint on that.
Even better, if you can, try to debug MdcActivationListener#before() and see if things work as expected.

Sorry for the delayed response Eyal, I was OoO.

Jira provides us with log4j 1.2.17.

I'll turn on debugging and report back to you.

Kind regards,
Pablo

Hi Eyal,

I set the log_level to debug and also tried debugging the jvm, but I have no clue what I should be looking for.

Could you please give me a hint?