Which is the best viewer for NLog?

Pierre8r picture Pierre8r · Jun 30, 2011 · Viewed 30.1k times · Source

Which is the best viewer for NLog?

log2console

sentinel

Other ?

Answer

Lockszmith picture Lockszmith · Mar 13, 2012

Although a very old question, the same question has been haunting me this last couple of weeks. Here is my little contribution to the hive-mind:

I found that for a lightweight client or client/server application using a simplistic, lightweight log viewer like log2console with NLogViewer target' filled with additional parameters fields made it both easy to use/setup and customize, while being readable and easy to find the info I looked for.

I used a UDP listener in the log viewer, and the following target definition in my NLog configuration:

<target xsi:type="NLogViewer" name="logviewer" address="udp://localhost:7071" onOverflow="Split">
    <parameter name="Message&#9;&#9;" layout="${message}" />
    <parameter name="Callsite&#9;&#9;" layout="${callsite:includSourcePath=true}"/>
    <parameter name="Exception&#9;" layout="${exception:separator=&#13;&#10;----&#13;&#10;:innerExceptionSeparator=&#13;&#10;-- -- -- -- --&#13;&#10;:maxInnerExceptionLevel=5:format=Message,Type,StackTrace:innerFormat=Message,Type,StackTrace}" />
    <parameter name="StackTrace&#9;" layout="${newline}&#9;${stacktrace_custom}" />
</target>

Notes:

  1. The &#9; is tab, which helps make it a bit more readable.
  2. The &#13;&#10; is newline, since I couldn't use ${newline} in a layout renderer's parameter (an NLog limitation).
  3. In my example I use a very detailed layout, you can of course edit it however you like, use the $exception layout renderer doc page for reference.

Hope someone finds this helpful