Files
tbf/AppDiagnostic.Logging

AppDiagnostic.Logging

Reusable NLog target for sending structured diagnostic events from multiple .NET Framework processes to AppDiagnostic.exe through a local named pipe.

Producer integration

Reference this project from the producer application and add the extension and target to its NLog configuration:

<extensions>
  <add assembly="AppDiagnostic.Logging" />
</extensions>

<targets>
  <target name="appDiagnostic"
          xsi:type="AppDiagnostic"
          layout="${message}" />
</targets>

<rules>
  <logger name="*" minlevel="Trace" writeTo="appDiagnostic" />
</rules>

The target writes to a bounded background queue. Producer threads are not blocked while the diagnostic viewer is unavailable. Queued messages are sent after the viewer becomes available; new messages are discarded when the queue limit is reached.

The receiver can read messages with:

DiagnosticLogEntry entry =
    DiagnosticMessageSerializer.ReadFramed(namedPipeServerStream);