Broadcast your serversĀ“ logs to websocket connections in real-time with minimal effort. Subscribe to a regular expressions to remove undesired lines. Simplifies log monitoring, allowing that a simple web browser to watch over multiple serversĀ“ logs interpolating the lines by timestamp. Not a replacement of a proper monitoring tool, but handy for watching over logs with little logistic effort.

NLog.Contrib.Targets.WebSocketServer is a NLog target that instead of writing on a file, or showing the log on the console, broadcast the log entries to the connected websocket connections.


Checkout this example of a log viewer done in AngularJS.



PM> Install-Package NLog.Contrib.Targets.WebSocketServer


Configure NLog.Contrib.Targets.WebsocketServer as a new target.

Required configuration parameters:

Optional configuation parameters:

    <!-- This part is only required for NLog versions < 4.0  -->
      <add assembly="NLog.Contrib.Targets.WebsocketServer"/>

      <target type="Console" name="consolelog" />
      <target name="logfile" type="File" fileName="file.txt" />

      <!-- Configuration for NLog.Targets.WebSocketServer -->
      <target name="websocket" type="NLog.Contrib.Targets.WebsocketServer" port="9001"/>
      <logger name="*" minlevel="Trace" writeTo="logfile, websocket, consolelog" />


The WebSocket server broadcast JSON objects like this:

   "Line":"2015-07-16 21:55:38.2576|INFO||This is information."


The component accepts JSON commands to request special behaviours.

Filter by Regular Expression

Instructs the component to only send the lines that match a give Regular Expression. Send an empty or null expression to reset it.

   "filter": <RegEx>