How to enable WinHttp Tracing on Vista, 2008 and Windows 7


WinhttpTracecfg.exe for Vista does not exist, so how can you get a WinHttp trace in Vista and above?

WinHttpTraceCfg.exe has been replaced in Vista and above with the netsh winhttp command.
see this blog:
http://blogs.msdn.com/wndp/archive/2007/03/21/winhttp-configuration-for-windows-vista.aspx

NOTE:  For 32 bit tracing on a 64 bit system you need to use the 32 bit netsh from the SysWOW64 directory.  This goes for proxy settings as well!  This netsh is located in the C:\Windows\SysWOW64 directory (if you did a default install).

A typical command to enable full tracing for WinHttp would look like this:

C:\Windows\system32>netsh winhttp set tracing trace-file-prefix=”C:\Temp\WinHttpLog” level=verbose format=hex state=enabled

For a 32 bit process on a 64 bit OS it would be from the SysWOW64 dir like this:

C:\Windows\SysWOW64>netsh winhttp set tracing trace-file-prefix=”C:\Temp\WinHttpLog” level=verbose format=hex state=enabled

You would reproduce the issue and then turn off tracing like this:

C:\Windows\system32>netsh winhttp set tracing state=disabled

 This would leave the other parameters you set previously to remain so the next time you want to enable tracing simply type:

C:\Windows\system32>netsh winhttp set tracing state=enabled

 

Other parameters are available:

C:\Windows\system32>netsh winhttp set tracing

will show you the options:

Usage:  set tracing
        [output=]file|debugger|both
        [trace-file-prefix=]<string>
        [level=]default|verbose
        [format=]ansi|hex
        [max-trace-file-size=]<number>
        [state=]enabled|disabled

Parameters:

  Tag                   Value
  trace-file-prefix   – Prefix for the log file (can include a path)
                        specify “*” to delete an existing prefix
  output              – Where the trace entries are written/displayed to
  level               – How much information to log
  format              – Display format of network traffic (hex or ansi)
  max-trace-file-size – Maximum size of the trace file (in bytes)
  state               – Enables or disables winhttp tracing

Examples:

  set tracing trace-file-prefix=”C:\Temp\Test3″ level=verbose format=hex
  set tracing output=debugger max-trace-file-size=512000 state=enabled

You can display the existing settings with this command:

C:\Windows\system32>netsh winhttp show tracing

Current WinHTTP Tracing settings:

    Tracing is not enabled.

    Trace File Prefix: C:\Temp\Test3
    Trace Output: file
    Trace Level:  verbose (headers, APIs, and entity body)
    Network Traffic Format: hex
    Maximum size of trace file (in bytes): 65535

Let me know if this helps!

Comments (4)

  1. Red Dutta says:

    I found your post and maybe you can help.  When I enter

    netsh winhttp set tracing trace-file-prefix="C:UsersRedDocumentsWinHTTPLog" format=ansi state=enabled

    But I always get

      Error writing tracing settings. (5) Access is denied.

    Do you know what I might be doing wrong?

  2. jpsanders says:

    Try Running the command from an elevated command prompt.  Hit the Windows Start button, then type cmd.  You should see cmd.exe in the list,  Right click on that and choose 'Run as Administrator'

    Let me know if that does it!

  3. Eduan Gerber says:

    Thanks a lot!

    It worked for me!! 😉

  4. EKurnia says:

    works wonders! ta!