For the past year I have recommending all developers/architects to make it a practice to use a real-time log viewer when working with C# code. A real-time log viewer allows you to examine all log messages generated by your C# applications (as they occur) and it also allows you to filter and sort these log messages. This can offer great productivity benefits are you develop and debug code. It is specially beneficial when troubleshooting multiple asynchronous processes in a solution.
The real-time log viewer I was recommending everyone to use was called “Legit Log Viewer” – but this application is no longer supported by its developer anymore so I found an alternative solution.
Today I am recommending a much better real-time log viewer that will offer you even more capabilities in examining the execution of your C# application code.
Name of the software: Gibraltar Loupe Client (Current version is 4.0)
You can download it here: LoupeClient.exe
The Gibraltar Loupe Client real-time logger will:
- automatically capture all NLog messages from your C# app
(no need to run the client in admin mode as was required by Legit Log Viewer)
- capture environment information about your C# application
- automatically log when assemblies are loaded at runtime
- capture the thread ID, Name and Type (i.e. Background, Pooled) that generated the log message
- show the C# line of code where the exception occurs with a link to the local file
- show a snippet of the c# code where the log message was generated
- can export logs to Excel
- save the log messages generated by previous applications executions so that you can review them later
- captures application metrics (memory usage, process utilization, etc.) during program execution (Nice feature)
Installing the Loupe client:
Installing the client is pretty straight forward. Simply run the EXE.
Configuring your C# application to send log messages to the Loupe client:
Make sure that your C# application has the following nugets installed:
Add the following lines to your NLog.config file:
<!--Contains GibraltarTarget class marked as "Gibraltar" target type-->
<add assembly="Gibraltar.Agent.NLog2" />
<!--Define a named target using the "Gibraltar" target type-->
<target name="Gibraltar" xsi:type="Gibraltar" />
<!--Sends all log messages to the "Gibraltar" named target-->
<logger name="*" minlevel="Trace" writeTo="Gibraltar" />
If you are working on a C# MVC solution that already uses the nuget Cmc.Core, then simply follow these steps:
- Install the Gibraltar.Agent.NLog2 nuget package
The installation will automatically update your web.config.
It will add 2 new sections: ‘gibraltar’ and ‘nlog’** You may want to move the NLog configuration settings added to the web.config to your NLog.config in order to make it easier to maintain your logging settings.
Getting started using the Loupe client:
To start viewing real-time log messages:
- Start up the Loupe client.
- On the left area, look for Home -> Local Sessions -> Live Sessions
- You will see any current apps that are sending log messages to the client listed under “Live Sessions”
- Double-click on the specific session listed in order to see all messages being logged for that particular session