Documentation - System.Diagnostics.Trace TraceListener
Harvester will always capture all System.Diagnostics.Debug and System.Diagnostics.Trace output in Microsoft .NET 3.5 or earlier applications. However, However, starting with Microsoft .NET 4.0 and Visual Studio 2010, a native debugger is always attached when debugging a managed application in Visual Studio. As only a single native debugger may capture OutputDebugString messages, Harvester will not be able to capture log messages if debugging your application in Visual Studio 2010.
In order to capture log messages for a Microsoft .NET 4.0 or latter application while debugging use the Harvester Trace Listener documented below.
Harvester Trace Listener
Recommended for Microsoft .NET 4.0 or later applications!
Harvester provides a custom trace listener to facilitate capturing log messages regardless of whether or not a native debugger is attached. The Harvester trace listener allows you to configure the type of message buffer used along with the corresponding binding and mutex name.
<system.diagnostics>
<trace>
<listeners>
<add name="HarvesterListener"
type="Harvester.Integration.Diagnostics.HarvesterListener, Harvester.Integration.TraceListener, Version=2.1.1.0, Culture=neutral, PublicKeyToken=2335e074c59acad6"
initializeData="Binding = \\.\pipe\Harvester; Buffer Type = NamedPipeBuffer; Mutex Name = HarvesterMutex;"/>
</listeners>
</trace>
</system.diagnostics>
Binding
A valid binding must be provided based on the selected buffer type.
- NamedPipeBuffer - Must be a valid local pipe name (i.e., \\.\pipe\SomeName).
- SharedMemoryBuffer - Must be a valid memory mapped file name (i.e., Local\SomeName or Global\SomeName).
Note: A binding name must correspond to a configured Harvester listener.
Buffer Type
Currently two buffer types are supported:
- NamedPipeBuffer - Recommend buffer type for all applications.
- SharedMemoryBuffer - Legacy buffer type supported by Harvester prior to version 2.0.0.
Note: Using a SharedMemoryBuffer for applications hosted in IIS is not supported.
Mutex Name
The mutex name that corresponds to the bound Harvester listener.
IMPORTANT: The Harvester mutex uses `LOCAL\` scope by default; change the MutexName to `GLOBAL\HarvesterMutex` if the mutex must be shared across multiple user sessions (i.e., capturing log messages from IIS, Windows Services or any other user session).
The corresponding <listener /> element in the Harvester configuration file(s) may also need to be updated from `HarvesterMutex` to `GLOBAL\HarvesterMutex`.