How can you correlate logs with APM?

Hey @NoviceESCoder,

with "multiple services" I mean multiple processes - or in other words multiple ASP.NET Core processes talking calling each other.

When you use return RedirectToAction the original HTTP call returns with status code 302 and the browser creates a new HTTP call - so technically the 2 calls are not related. In my A -> B -> C example I talk about different services calling each other - so in your 1. servicer you'd have an outgoing HTTP call to another service (which could also run on a different machine).

If you want to test it with 1 process, then 1 thing you could do is to just do an outgoing HTTP request to another controller with HttpClient - that'd be a simulation where you'd see distributed tracing and log correlation working. But again, the main point is to do this across multiple services (processes) and correlation those.

Regarding where to put the .Enrich.WithElasticApmCorrelationInfo() call:

You should configure the logger only one during the startup and not in the controller - Look at the serilog ASP.NET Core instructions here - just do the same and call .Enrich.WithElasticApmCorrelationInfo() on the LoggerConfiguration from the code-snippet. With that you configure the logger once during startup (including adding the APM enricher).