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!

Rock solid centralized logging

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