Enabling/disabling tracing from a script

Apr 12, 2011 at 3:09 PM

Hi,

I'm not sure if this is the right forum for this kind of question, so if it isn't, please advise.

After successfully instrumenting my application using NTrace, I want to give the user a script for enabling/disabling tracing.

After doing some research, I've found the logman.exe utility, which seems to be the exact tool I need. I started playing with it and noticed that in order to create/start trace session, I need to give the provider name/guid as a parameter (-p option) - I tried using the guid I set as the EtwProviderId, 'logman create' seemed to return successfully, however after running my application and stopping the trace session, I got a trace file containing just headers. I ran 'logman query providers' and didn't find my application's guid among the listed providers.

If I understand correctly, I need to register my applications etw provider in some manner. Where can I find any guidelines about it? or am I missing something here and should go on another direction?

Thanks,

--Eran

Coordinator
Apr 12, 2011 at 6:52 PM
Hello! This is just as good a forum as any!

It should be something along these lines (I'm using '9e9fa021-37a6-46e7-b42a-b035b1736ca8' for my provider ID, yours will of course be different):
logman create trace "Test" -p {9e9fa021-37a6-46e7-b42a-b035b1736ca8} 255 7 -o test.etl
logman start "Test"
<run your app>
logman stop "Test"
logman delete "Test"

This will result in the trace spew being written to a binary file named "test(some unique number).etl." In general, this is what you'd have a customer zip up and send you; it's going to be reasonably compact, as it's just the raw data and does not contain any formatting. Once you generate/obtain this file, you need to get it formatted for human consumption. To do this, we can use TraceView (as mentioned in the NTrace site) or you can use the tracefmt tool:

tracefmt test(some unique number).etl -p <Path to your app's TMF files, e.g.: C:\MyProject\bin\Debug\Trace>

The tracefmt tool emits a pair of files: FmtFile.txt (human-readable format) and FmtSum.txt (a summary of the formatting pass).

For completeness' sake, here's how you'd do it with tracelog.exe:
tracelog -start Test -guid #9e9fa021-37a6-46e7-b42a-b035b1736ca8 -flag 255 -level 7 -f test.etl
tracefmt test.etl -p <Path to your app's TMF files, e.g.: C:\MyProject\bin\Debug\Trace>

If you want to do real-time tracing (akin to running DbgView to see the trace spew in real-time), use the following:
logman create trace Test -p {9e9fa021-37a6-46e7-b42a-b035b1736ca8} 255 7 -rt
(or tracelog -start Test -guid #9e9fa021-37a6-46e7-b42a-b035b1736ca8 -flag 255 -level 7 -rt)
tracefmt -rt Test -p <Path to your app's TMF files, e.g.: C:\MyProject\bin\Debug\Trace> -display

The tracefmt tool is delivered with the newer versions of the Windows SDK. TraceView and tracelog are available as part of the Windows Device Driver Kit.

Hope this helps!
-Andy Hopper

On Tue, Apr 12, 2011 at 11:09 AM, eranhare <notifications@codeplex.com> wrote:

From: eranhare

Hi,

I'm not sure if this is the right forum for this kind of question, so if it isn't, please advise.

After successfully instrumenting my application using NTrace, I want to give the user a script for enabling/disabling tracing.

After doing some research, I've found the logman.exe utility, which seems to be the exact tool I need. I started playing with it and noticed that in order to create/start trace session, I need to give the provider name/guid as a parameter (-p option) - I tried using the guid I set as the EtwProviderId, 'logman create' seemed to return successfully, however after running my application and stopping the trace session, I got a trace file containing just headers. I ran 'logman query providers' and didn't find my application's guid among the listed providers.

If I understand correctly, I need to register my applications etw provider in some manner. Where can I find any guidelines about it? or am I missing something here and should go on another direction?

Thanks,

--Eran

Read the full discussion online.

To add a post to this discussion, reply to this email (NTrace@discussions.codeplex.com)

To start a new discussion for this project, email NTrace@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Apr 13, 2011 at 5:39 AM

Thanks much for the detailed answer!