This project is read-only.

NLog Configuration

Integrating your application with Harvester is as easy as adding an additional target to the NLog configuration section.

Typical Configuration

The typical configuration requires that NLog be configured with an OutputDebugString target.

<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <targets>
    <target xsi:type="OutputDebugString" name="DbWin" layout="Log4JXmlEventLayout">
      <layout xsi:type="Log4JXmlEventLayout" />
    </target>
  </targets>
  <rules>
    <logger name="*" minlevel="Trace" writeTo="DbWin" />
  </rules>
</nlog>
IMPORTANT: Harvester will capture all output regardless of message format, but for optimal results, a layout of Log4JXmlEventLayout must be used.

When using applications developed against the Microsoft .NET Framework 3.5 or earlier, all output will be captured by Harvester regardless of whether or not a debugger has been attached (i.e., launched via F5 or CTRL-F5). However, if developing an application with the Microsoft .NET Framework 4.0 or later, output will NOT be captured by Harvester when a debugger has been attached (i.e., launched with F5). If you prefer to not use the custom target documented below, launch your application without the debugger (i.e., CRTL-F5) to capture log output in Harvester.

Why is my Microsoft .NET 4.0+ Application Not Capturing Output When Debugging!

With the latest version of the CLR, Microsoft has opted to always attach a Native debugger when you are debugging your managed application(s) in Visual Studio 2010. As only a single native debugger may be attached to a given process at any one time, Harvester cannot capture the OutputDebugString messages from your application when launched in Visual Studio with a debugger attached (i.e., launched with F5). To work around the issue, a custom NLog target has been created that will capture all OutputDebugString messages and write them to a separate message buffer that Harvester can capture regardless of a debugger being attached to your application.

<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <extensions>
    <add assembly="Harvester.Integration.NLog, Version=1.1.188.834, Culture=neutral, PublicKeyToken=2335e074c59acad6"/>
  </extensions>
  <targets>
    <target xsi:type="Harvester" name="Harvester" />
  </targets>
  <rules>
    <logger name="*" minlevel="Trace" writeTo="Harvester" />
  </rules>
</nlog>
IMPORTANT: Harvester will capture all output regardless of message format, but for optimal results, a layout of Log4JXmlEventLayout must be used (default).

Last edited Aug 19, 2011 at 1:43 AM by CBaxter, version 2

Comments

No comments yet.