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.."/>
.net logging event-log tracing etw
add a comment |
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.."/>
.net logging event-log tracing etw
add a comment |
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.."/>
.net logging event-log tracing etw
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
.net logging event-log tracing etw
edited Nov 14 at 6:37
asked Nov 6 at 13:37
mehmetilker
121113
121113
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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