title: Debug|Trace.WriteLine from C# plugin in Visual Studio - display via ConsoleTraceListener
body: <p>I've modified a C# plugin that's part of Python Tools for Visual Studio 2.0, and want to see the output from Debug.WriteLine and Trace.WriteLine statements in the code.  Note that the plugin is used in Visual Studio 2013 itself, modifying debugging of python processes....</p>
  
  <p>I'm hoping I can add a trace listener in <code>devenv.exe.config</code> as suggested by pminaev <a href="https://pytools.codeplex.com/discussions/544779#post1243421" rel="nofollow">on the PTVS discussion forum here</a> (attaching another VS to VS itself seems clumsy so I'm hoping to avoid that).</p>
  
  <p><strong><em>What I believe to be correct config for other .NET applications doesn't seem to work for VS2013 itself.</em></strong>  My efforts are documented below.</p>
  
  <p>If anyone's managed to redirect plugin debug/trace output to the Visual Studio Console (or anywhere else more convenient than another attached VS instance), tips greatly appreciated....</p>
  
  <hr>
  
  <p>My Google-fu turned up a couple examples, based on which I've tried adding...</p>
  
  <pre><code>&lt;system.diagnostics&gt;
      &lt;trace autoflush="true" /&gt;
          &lt;listeners&gt;
              &lt;add name="myConsoleTraceListener" type="System.Diagnostics.ConsoleTraceListener" /&gt;
          &lt;/listeners&gt;
      &lt;/trace&gt;
  &lt;/system.diagnostics&gt;
  </code></pre>
  
  <p>...and...</p>
  
  <pre><code>&lt;system.diagnostics&gt;
      &lt;source name="System.ServiceModel.MessageLogging" switchValue="Verbose, ActivityTracing"&gt;
          &lt;listeners&gt;
              &lt;add name="myTraceListener" /&gt;
          &lt;/listeners&gt;
      &lt;/source&gt;
      &lt;sharedListeners&gt;
          &lt;add name="myTraceListener" type="System.Diagnostics.ConsoleTraceListener" /&gt;
      &lt;/sharedListeners&gt;
  &lt;/system.diagnostics&gt;
  </code></pre>
  
  <p>Starting PTVS afterwards, nothing's usable.  With either config I get a popup:</p>
  
  <pre><code>The `Python Tools Package' package id not load correctly.
  
  The problem may have been caused by a configuration change or by
  the installation of another extension.  You can get more information by
  examining the file
  'C:\Users\XXX\AppData\Roaming\Microsoft\VisualStudio\12.0\Acti
  vityLog.xml'.
  </code></pre>
  
  <p>The ActivityLog doesn't mean much to me:</p>
  
  <pre><code>&lt;entry&gt;
      &lt;record&gt;41&lt;/record&gt;
      &lt;time&gt;2014/05/12 07:52:47.851&lt;/time&gt;
      &lt;type&gt;Error&lt;/type&gt;
      &lt;source&gt;VisualStudio&lt;/source&gt;
      &lt;description&gt;CreateInstance failed for package [Python Tools Package]&lt;/description&gt;
      &lt;guid&gt;{6DBD7C1E-1F1B-496D-AC7C-C55DAE66C783}&lt;/guid&gt;
      &lt;hr&gt;80131604&lt;/hr&gt;
      &lt;errorinfo&gt;Exception has been thrown by the target of an invocation.&lt;/errorinfo&gt;
  &lt;/entry&gt;
  &lt;entry&gt;
      &lt;record&gt;42&lt;/record&gt;
      &lt;time&gt;2014/05/12 07:52:47.851&lt;/time&gt;
      &lt;type&gt;Error&lt;/type&gt;
      &lt;source&gt;VisualStudio&lt;/source&gt;
      &lt;description&gt;End package load [Python Tools Package]&lt;/description&gt;
      &lt;guid&gt;{6DBD7C1E-1F1B-496D-AC7C-C55DAE66C783}&lt;/guid&gt;
      &lt;hr&gt;80004005 - E_FAIL&lt;/hr&gt;
      &lt;errorinfo&gt;Exception has been thrown by the target of an invocation.&lt;/errorinfo&gt;
  &lt;/entry&gt;
  </code></pre>
  
  <p>When I try to attach to the remote python process I get another popup:</p>
  
  <pre><code>Unable to connect to 'secret@server'.  Operation not supported.
  Unknown error: 0x80131902.
  </code></pre>
  
  <p>Google-foo suggests this is some failure to load a .NET version...?</p>