Using Loupe with Trace

Behind Advent door number 19 is a simple treat - how to use Loupe with the logging capabilities of .NET.

As soon as the Loupe Agent is started within a process it begins listening to a number of sources of information, including:

  • Trace Messages:  Anything sent to System.Diagnostics.Trace will be routed into the Agent.
  • Console Messages: If you write text to System.Console it will be copied into the Agent as well as sent on to any Console.
  • Debug Messages: In a debug build anything written to System.Diagnostics.Debug will be output to any Trace listener and therefore routed to the Agent.

Since many third-party and Microsoft components send useful information to Trace Loupe automatically registers itself as a Trace Listener as soon as the agent is loaded (as well as registering to get a copy of all console messages) so there’s no configuration needed on your part.  The only thing you need to worry about is that the Loupe Agent is actually started and eventually told to shut down.  If you’re running in an ASP.NET application there’s nothing to do for this- the Gibraltar Agent for ASP.NET takes care of it all.  Otherwise, you should explicitly start the agent early on in your application’s lifecycle and then shut it down when you’re sure your application is exiting.  For details see:

After that, you can freely send information strait to Trace, Debug, or Console and be sure that it’ll be captured by the Loupe Agent.  If you have a third-party library that supports Trace you can enable that logging and it’ll get captured as well.

*Whew* That was easy!

Related Posts

PostSharp Diagnostics Now Supports Loupe in the Box

The latest update to PostSharp Diagnostics adds Loupe support, enabling extensive high-performance logging to be added to any .NET application with virtually no code changes. PostSharp even has a great free option for developers that complements Loupe Desktop! Read more

Loupe Agent for .NET Core Now Available

The first release of the Loupe Agent for .NET Core is also our first open source version of the Loupe Agent. This is the first step in our plan to open source the entire Loupe Agent to make it easier for anyone to extend and take advantage of what Loupe... Read more

We've Moved Loupe Service to App.OnLoupe.Com

Loupe Service now has a shorter, direct site name that's faster, anywhere in the world. Just to go App.OnLoupe.Com, the new CDN-accelerated endpoint for the Loupe Service. Your existing Agents and Loupe Desktops are unaffected by this change, but access to the web UI will be redirected to the new... Read more

Rock solid centralized .NET logging

Unlimited applications, unlimited errors, scalable from solo startup to enterprise.