Search code examples
c#nloglogentries

Params in LogEntries configuration


Using the default configuration for LogEntries, is it possible to create insert parameterized values into the layout?

<nlog>
    <extensions>
      <add assembly="LogentriesNLog" />
    </extensions>
    <targets>
      <target name="logentries" type="Logentries" debug="true" httpPut="false" ssl="false" layout="${date:format=ddd MMM dd} ${time:format=HH:mm:ss} ${date:format=zzz yyyy} ${logger} {SOME PARAM FROM CONFIG} : ${LEVEL}, ${message}">

      </target>
    </targets>
    <rules>
      <logger name="*" minLevel="Trace" appendTo="logentries" />
    </rules>
</nlog>

Solution

  • I'm an idiot sometimes.

    You can just stick them in the layout string

    <target name="logentries" type="Logentries" debug="true" httpPut="false" ssl="false" layout="${date:format=ddd MMM dd} ${time:format=HH:mm:ss} ${date:format=zzz yyyy} : ${LEVEL}, ${message}, ${SomeParam}"></target>