El seguimiento .NET no funciona con Diagnostics.TraceSource, solo Diagnostics.Trace

Estoy tratando de configurar el seguimiento .NET. Puedo obtener el rastreo básico para que funcione a través de System.Diagnostics.Trace, pero por razones complicadas tengo que activar el rastreo a través de objetos System.Diagnostics.TraceSource (la nueva forma de hacerlo, desde .NET 2.0) en lugar de usar System .Diagnóstico.Traza. He intentado todo pero simplemente no quiere trabajar con TraceSource. Estoy realizando el seguimiento en un código ASP.NET subyacente (aspx.cs)

Aquí hay algunas URL relacionadas:

http://msdn.microsoft.com/en-us/library/ty48b824.aspx
http://msdn.microsoft.com/en-us/library/64yxa344.aspx
http://msdn.microsoft.com/en-us/library/sk36c28t.aspx
http://blogs.msdn.com/b/bclteam/archive/2005/03/15/396431.aspx
http://msdn.microsoft.com/en-us/library/b0ectfxd%28v=VS.100%29.aspx

Actualmente, basado en lo que está en web.config, debería estar rastreando tanto a un archivo como a la página, desde este código:

TraceSource ts = new TraceSource("mysource", SourceLevels.All);
Trace.Write("Trace (old way)"); // this one works
ts.TraceInformation("Trace (new way)"); // this one doesn't work
ts.Flush();
ts.Close();

Aquí están las secciones web.config que son relevantes:

 <system.diagnostics>
       <trace autoflush="false">
            <listeners> <!-- these listeners activate the "old way" of tracing. -->
                 <add       name="pagelistener" />
                 <add       name="filelistener" />
            </listeners>
       </trace>

       <sources>
            <source name="mysource" switchName="myswitch">
                 <listeners>  <!-- these listeners activate the "new way" -->
                       <add name="pagelistener" />
                       <add name="filelistener" />
                 </listeners>
            </source>
       </sources>


       <sharedListeners> 
            <!-- these are the actual trace listeners -->
            <add
                  name="filelistener"
                 type="System.Diagnostics.TextWriterTraceListener"
                 initializeData="loplog.txt"
                 />
            <add
                 name="pagelistener"
                 traceOutputOptions="none"
                 type="System.Web.WebPageTraceListener, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
                 />
       </sharedListeners>

       <switches>
            <!-- the sources above use this verbose switch -->
            <add name="myswitch" value="Verbose"/>
       </switches>

 </system.diagnostics>
 <system.codedom>
       <!-- this compilers section should not be needed because I added
                 #define TRACE to the .aspx.cs file, however I put this in
                 since it's still not working. -->

       <compilers>
            <compiler
                            language="c#;cs;csharp"
                            extension=".cs"
                            compilerOptions="/d:TRACE"
                            type="Microsoft.CSharp.CSharpCodeProvider, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
                            warningLevel="1"
                            />
       </compilers>
 </system.codedom>

 <system.web>
       <!-- this trace tag should be redundant because I added trace="true" to the aspx file,
                 but I put it in here anyway because this wasn't working. -->
       <trace writeToDiagnosticsTrace="true" enabled="true" pageOutput="true" requestLimit="50" localOnly="true"/>

Respuestas a la pregunta(1)

Su respuesta a la pregunta