Cannot read EventProviderTraceListener logs with code











up vote
0
down vote

favorite












I am using following code to read ETW logs for "ASP.NET Events" and other registered providers successfully.



using (var session = new TraceEventSession("TraceSessionTest"))
{
// Set up Ctrl-C to stop the session
Console.CancelKeyPress +=
(object s, ConsoleCancelEventArgs args) => session.Stop();
session.EnableProvider("ASP.NET Events");
using (var source = new ETWTraceEventSource("ObserveProcs", TraceEventSourceType.Session))
{
Console.WriteLine("Listening");
// Hook up the parser that knows about EventSources
DynamicTraceEventParser dynamicTraceEventParser = new DynamicTraceEventParser(source);
dynamicTraceEventParser.All += delegate (TraceEvent traceEvent2)
{
Console.WriteLine("n -------- Event: {0}", traceEvent2);
};
source.Process();
}
}


What I would like to do is that tracing outgoing request from certain application.
To do that I have added following configuration to that certain application config file.



<system.diagnostics>
<!--<trace autoflush="true"/>-->
<trace autoflush="true" indentsize="4">
<listeners>
<remove name="Default" />
<add name="EtwListener"
type="System.Diagnostics.Eventing.EventProviderTraceListener, System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
initializeData="{BDE5930E-34C9-4E2F-A6EC-89E1F1EA69CC}" />
</listeners>
</trace>
<sources>
<source name="System.Net">
<listeners>
<!--<add name="MyTraceFile"/>
<add name="MyConsole"/>-->
<add name="ETWListener" initializeData="{BDE5930E-34C9-4E2F-A6EC-89E1F1EA69CC}"
type="System.Diagnostics.Eventing.EventProviderTraceListener, System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
traceOutputOptions="LogicalOperationStack, DateTime, Timestamp, Callstack"/>
</listeners>
</source>
</sources>
<sharedListeners>
<!--<add name="MyTraceFile" type="System.Diagnostics.TextWriterTraceListener" initializeData="System.Net.trace.log" traceOutputOptions="Timestamp"/>
<add name="MyConsole" type="System.Diagnostics.ConsoleTraceListener"/>-->
<add name="ETWListener" type="System.Diagnostics.Eventing.EventProviderTraceListener, System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
initializeData="{BDE5930E-34C9-4E2F-A6EC-89E1F1EA69CC}" />
</sharedListeners>
<switches>
<add name="System.Net" value="Information"/>
</switches>




I am able to see trace logs with logman with following commands;




logman start "hellosession" -p '{BDE5930E-34C9-4E2F-A6EC-89E1F1EA69CC}' -o "hello.etl" -ets
--Made some request from the application to trigger some HttpWebRequest operation.
logman stop "hellosession" -ets
tracerpt hello.etl -of csv -o hello1.csv



But I am not able to see/read logs with code (change on code for provider guid - stated on initializeData)



session.EnableProvider(new Guid("{BDE5930E-34C9-4E2F-A6EC-89E1F1EA69CC}"), TraceEventLevel.Verbose);


This is not registered provider so that I assume this is why I can not see it provider list with "logman query provider".



Is there any other thing I need to subscribe EventProviderTraceListener from code?



Update: I can get exception trace logs like:



<Event MSec="447529,4150" PID="22260" PName=        "" TID="20412" IsClassic="False" ProviderName="Provider(bde5930e-34c9-4e2f-a6ec-89e1f1ea69cc)" FormattedMessage="[20412] Exception in HttpWebRequest#2155438::GetResponse - The remote server returned an error: (400) Bad Request.."/>









share|improve this question




























    up vote
    0
    down vote

    favorite












    I am using following code to read ETW logs for "ASP.NET Events" and other registered providers successfully.



    using (var session = new TraceEventSession("TraceSessionTest"))
    {
    // Set up Ctrl-C to stop the session
    Console.CancelKeyPress +=
    (object s, ConsoleCancelEventArgs args) => session.Stop();
    session.EnableProvider("ASP.NET Events");
    using (var source = new ETWTraceEventSource("ObserveProcs", TraceEventSourceType.Session))
    {
    Console.WriteLine("Listening");
    // Hook up the parser that knows about EventSources
    DynamicTraceEventParser dynamicTraceEventParser = new DynamicTraceEventParser(source);
    dynamicTraceEventParser.All += delegate (TraceEvent traceEvent2)
    {
    Console.WriteLine("n -------- Event: {0}", traceEvent2);
    };
    source.Process();
    }
    }


    What I would like to do is that tracing outgoing request from certain application.
    To do that I have added following configuration to that certain application config file.



    <system.diagnostics>
    <!--<trace autoflush="true"/>-->
    <trace autoflush="true" indentsize="4">
    <listeners>
    <remove name="Default" />
    <add name="EtwListener"
    type="System.Diagnostics.Eventing.EventProviderTraceListener, System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
    initializeData="{BDE5930E-34C9-4E2F-A6EC-89E1F1EA69CC}" />
    </listeners>
    </trace>
    <sources>
    <source name="System.Net">
    <listeners>
    <!--<add name="MyTraceFile"/>
    <add name="MyConsole"/>-->
    <add name="ETWListener" initializeData="{BDE5930E-34C9-4E2F-A6EC-89E1F1EA69CC}"
    type="System.Diagnostics.Eventing.EventProviderTraceListener, System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
    traceOutputOptions="LogicalOperationStack, DateTime, Timestamp, Callstack"/>
    </listeners>
    </source>
    </sources>
    <sharedListeners>
    <!--<add name="MyTraceFile" type="System.Diagnostics.TextWriterTraceListener" initializeData="System.Net.trace.log" traceOutputOptions="Timestamp"/>
    <add name="MyConsole" type="System.Diagnostics.ConsoleTraceListener"/>-->
    <add name="ETWListener" type="System.Diagnostics.Eventing.EventProviderTraceListener, System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
    initializeData="{BDE5930E-34C9-4E2F-A6EC-89E1F1EA69CC}" />
    </sharedListeners>
    <switches>
    <add name="System.Net" value="Information"/>
    </switches>




    I am able to see trace logs with logman with following commands;




    logman start "hellosession" -p '{BDE5930E-34C9-4E2F-A6EC-89E1F1EA69CC}' -o "hello.etl" -ets
    --Made some request from the application to trigger some HttpWebRequest operation.
    logman stop "hellosession" -ets
    tracerpt hello.etl -of csv -o hello1.csv



    But I am not able to see/read logs with code (change on code for provider guid - stated on initializeData)



    session.EnableProvider(new Guid("{BDE5930E-34C9-4E2F-A6EC-89E1F1EA69CC}"), TraceEventLevel.Verbose);


    This is not registered provider so that I assume this is why I can not see it provider list with "logman query provider".



    Is there any other thing I need to subscribe EventProviderTraceListener from code?



    Update: I can get exception trace logs like:



    <Event MSec="447529,4150" PID="22260" PName=        "" TID="20412" IsClassic="False" ProviderName="Provider(bde5930e-34c9-4e2f-a6ec-89e1f1ea69cc)" FormattedMessage="[20412] Exception in HttpWebRequest#2155438::GetResponse - The remote server returned an error: (400) Bad Request.."/>









    share|improve this question


























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I am using following code to read ETW logs for "ASP.NET Events" and other registered providers successfully.



      using (var session = new TraceEventSession("TraceSessionTest"))
      {
      // Set up Ctrl-C to stop the session
      Console.CancelKeyPress +=
      (object s, ConsoleCancelEventArgs args) => session.Stop();
      session.EnableProvider("ASP.NET Events");
      using (var source = new ETWTraceEventSource("ObserveProcs", TraceEventSourceType.Session))
      {
      Console.WriteLine("Listening");
      // Hook up the parser that knows about EventSources
      DynamicTraceEventParser dynamicTraceEventParser = new DynamicTraceEventParser(source);
      dynamicTraceEventParser.All += delegate (TraceEvent traceEvent2)
      {
      Console.WriteLine("n -------- Event: {0}", traceEvent2);
      };
      source.Process();
      }
      }


      What I would like to do is that tracing outgoing request from certain application.
      To do that I have added following configuration to that certain application config file.



      <system.diagnostics>
      <!--<trace autoflush="true"/>-->
      <trace autoflush="true" indentsize="4">
      <listeners>
      <remove name="Default" />
      <add name="EtwListener"
      type="System.Diagnostics.Eventing.EventProviderTraceListener, System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
      initializeData="{BDE5930E-34C9-4E2F-A6EC-89E1F1EA69CC}" />
      </listeners>
      </trace>
      <sources>
      <source name="System.Net">
      <listeners>
      <!--<add name="MyTraceFile"/>
      <add name="MyConsole"/>-->
      <add name="ETWListener" initializeData="{BDE5930E-34C9-4E2F-A6EC-89E1F1EA69CC}"
      type="System.Diagnostics.Eventing.EventProviderTraceListener, System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
      traceOutputOptions="LogicalOperationStack, DateTime, Timestamp, Callstack"/>
      </listeners>
      </source>
      </sources>
      <sharedListeners>
      <!--<add name="MyTraceFile" type="System.Diagnostics.TextWriterTraceListener" initializeData="System.Net.trace.log" traceOutputOptions="Timestamp"/>
      <add name="MyConsole" type="System.Diagnostics.ConsoleTraceListener"/>-->
      <add name="ETWListener" type="System.Diagnostics.Eventing.EventProviderTraceListener, System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
      initializeData="{BDE5930E-34C9-4E2F-A6EC-89E1F1EA69CC}" />
      </sharedListeners>
      <switches>
      <add name="System.Net" value="Information"/>
      </switches>




      I am able to see trace logs with logman with following commands;




      logman start "hellosession" -p '{BDE5930E-34C9-4E2F-A6EC-89E1F1EA69CC}' -o "hello.etl" -ets
      --Made some request from the application to trigger some HttpWebRequest operation.
      logman stop "hellosession" -ets
      tracerpt hello.etl -of csv -o hello1.csv



      But I am not able to see/read logs with code (change on code for provider guid - stated on initializeData)



      session.EnableProvider(new Guid("{BDE5930E-34C9-4E2F-A6EC-89E1F1EA69CC}"), TraceEventLevel.Verbose);


      This is not registered provider so that I assume this is why I can not see it provider list with "logman query provider".



      Is there any other thing I need to subscribe EventProviderTraceListener from code?



      Update: I can get exception trace logs like:



      <Event MSec="447529,4150" PID="22260" PName=        "" TID="20412" IsClassic="False" ProviderName="Provider(bde5930e-34c9-4e2f-a6ec-89e1f1ea69cc)" FormattedMessage="[20412] Exception in HttpWebRequest#2155438::GetResponse - The remote server returned an error: (400) Bad Request.."/>









      share|improve this question















      I am using following code to read ETW logs for "ASP.NET Events" and other registered providers successfully.



      using (var session = new TraceEventSession("TraceSessionTest"))
      {
      // Set up Ctrl-C to stop the session
      Console.CancelKeyPress +=
      (object s, ConsoleCancelEventArgs args) => session.Stop();
      session.EnableProvider("ASP.NET Events");
      using (var source = new ETWTraceEventSource("ObserveProcs", TraceEventSourceType.Session))
      {
      Console.WriteLine("Listening");
      // Hook up the parser that knows about EventSources
      DynamicTraceEventParser dynamicTraceEventParser = new DynamicTraceEventParser(source);
      dynamicTraceEventParser.All += delegate (TraceEvent traceEvent2)
      {
      Console.WriteLine("n -------- Event: {0}", traceEvent2);
      };
      source.Process();
      }
      }


      What I would like to do is that tracing outgoing request from certain application.
      To do that I have added following configuration to that certain application config file.



      <system.diagnostics>
      <!--<trace autoflush="true"/>-->
      <trace autoflush="true" indentsize="4">
      <listeners>
      <remove name="Default" />
      <add name="EtwListener"
      type="System.Diagnostics.Eventing.EventProviderTraceListener, System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
      initializeData="{BDE5930E-34C9-4E2F-A6EC-89E1F1EA69CC}" />
      </listeners>
      </trace>
      <sources>
      <source name="System.Net">
      <listeners>
      <!--<add name="MyTraceFile"/>
      <add name="MyConsole"/>-->
      <add name="ETWListener" initializeData="{BDE5930E-34C9-4E2F-A6EC-89E1F1EA69CC}"
      type="System.Diagnostics.Eventing.EventProviderTraceListener, System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
      traceOutputOptions="LogicalOperationStack, DateTime, Timestamp, Callstack"/>
      </listeners>
      </source>
      </sources>
      <sharedListeners>
      <!--<add name="MyTraceFile" type="System.Diagnostics.TextWriterTraceListener" initializeData="System.Net.trace.log" traceOutputOptions="Timestamp"/>
      <add name="MyConsole" type="System.Diagnostics.ConsoleTraceListener"/>-->
      <add name="ETWListener" type="System.Diagnostics.Eventing.EventProviderTraceListener, System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
      initializeData="{BDE5930E-34C9-4E2F-A6EC-89E1F1EA69CC}" />
      </sharedListeners>
      <switches>
      <add name="System.Net" value="Information"/>
      </switches>




      I am able to see trace logs with logman with following commands;




      logman start "hellosession" -p '{BDE5930E-34C9-4E2F-A6EC-89E1F1EA69CC}' -o "hello.etl" -ets
      --Made some request from the application to trigger some HttpWebRequest operation.
      logman stop "hellosession" -ets
      tracerpt hello.etl -of csv -o hello1.csv



      But I am not able to see/read logs with code (change on code for provider guid - stated on initializeData)



      session.EnableProvider(new Guid("{BDE5930E-34C9-4E2F-A6EC-89E1F1EA69CC}"), TraceEventLevel.Verbose);


      This is not registered provider so that I assume this is why I can not see it provider list with "logman query provider".



      Is there any other thing I need to subscribe EventProviderTraceListener from code?



      Update: I can get exception trace logs like:



      <Event MSec="447529,4150" PID="22260" PName=        "" TID="20412" IsClassic="False" ProviderName="Provider(bde5930e-34c9-4e2f-a6ec-89e1f1ea69cc)" FormattedMessage="[20412] Exception in HttpWebRequest#2155438::GetResponse - The remote server returned an error: (400) Bad Request.."/>






      .net logging event-log tracing etw






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 14 at 6:37

























      asked Nov 6 at 13:37









      mehmetilker

      121113




      121113





























          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53173061%2fcannot-read-eventprovidertracelistener-logs-with-code%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown






























          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53173061%2fcannot-read-eventprovidertracelistener-logs-with-code%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          這個網誌中的熱門文章

          Tangent Lines Diagram Along Smooth Curve

          Yusuf al-Mu'taman ibn Hud

          Zucchini