Documentation - Log4Net HarvesterAppender
Integrating your application with Harvester is as easy as adding an additional appender to the Log4Net configuration section.
OutputDebugString Appender
Recommended for Microsoft .NET 3.5 or earlier applications!
Log4Net's built in OutputDebugString appender is a viable option to push debug messages to Harvester. The OutputDebugString appender will work with Microsoft .NET 3.5 and earlier applications regardless of whether or not you are debugging within Visual Studio. 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 Appender documented below.
<log4net>
<appender name="OutputDebugStringAppender" type="log4net.Appender.OutputDebugStringAppender" >
<layout type="log4net.Layout.XMLLayout" />
</appender>
<root>
<level value="DEBUG" />
<appender-ref ref="OutputDebugStringAppender" />
</root>
</log4net>
Note: Harvester will capture all application output regardless of message format, but for optimal results, a layout of XmlLayout should be used.
Harvester Appender
Recommended for Microsoft .NET 4.0 or later applications!
Harvester provides a custom appender to facilitate capturing log messages regardless of whether or not a native debugger is attached. The Harvester appender allows you to configure the type of message buffer used along with the corresponding binding and mutex name.
<log4net>
<appender name="HarvesterAppender" type="Harvester.Integration.Log4Net.HarvesterAppender, Harvester.Integration.Log4Net, Version=2.1.1.0, Culture=neutral, PublicKeyToken=2335e074c59acad6">
<binding value="\\.\pipe\Harvester" />
<bufferType value="NamedPipeBuffer" />
<mutex value="HarvesterMutex" />
</appender>
<root>
<level value="DEBUG" />
<appender-ref ref="HarvesterAppender" />
</root>
</log4net>
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.
BufferType
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.
MutexName
The mutex name that correspond 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`.