.NET Core API Log correlation not showing in transactions

Hi I'm trying to make log correlation work on my NET Core API.
I'm using NLog following the documentation. I'm getting the traceID and transactionID in the logs in my console and logfile but I have zero logs in any APM Transactions.
What am I missing?


Here is my NLog config


<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd"
      autoReload="true"
      throwExceptions="false"
      internalLogLevel="Off" internalLogFile="nlog-internal.log">

    <extensions>
      <add assembly="Elastic.Apm.NLog"/>
      <add assembly="Elastic.CommonSchema.NLog"/>
      <add assembly="NLog.Web.AspNetCore"/>
    </extensions>
  <targets>
    
  <target name="console"
            type="console"
            layout="${ElasticApmTraceId}|${ElasticApmTransactionId}|${ElasticApmSpanId}|${message}" />
  
    <target type="file" name="logfile" fileName="myfile.txt" >
      <layout type="jsonlayout">
        <attribute name="TraceId" layout="${ElasticApmTraceId}" />
        <attribute name="TransactionId" layout="${ElasticApmTransactionId}" />
        <attribute name="Date" layout="${longdate}" />
        <attribute name="Level" layout="${uppercase:${level}}" />
        <attribute name="Logger" layout="${logger}" />
        <attribute name="Message" layout="${message} ${exception:format=tostring}" />
      </layout>
    </target>
  </targets>
  
  <rules>
    <logger name="*" minLevel="Debug" writeTo="Console" />
    <logger name="*" minLevel="Trace" writeTo="logfile" />
  </rules>
</nlog>

1 Like

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