HTTP logging

  • Revision slug: HTTP_Logging
  • Revision title: HTTP Logging
  • Revision id: 13748
  • Created:
  • Creator: Agradman
  • Is current revision? No
  • Comment underline into bold; 3 words added, 3 words removed

Revision Content

This page contains instructions for how to use Mozilla's built-in logging facility to capture HTTP activity in Firefox.  The presentation is designed for people who are unfamiliar with Mozilla (or computers in general).  If you are such a person, simply look at the "Logging HTTP activity" section below.

If you are referring such a person to this page, please make clear to them where you want them to perform variations on these generic instructions.  The "Excluding specific portions of HTTP activity" section below provides some common variations for focusing the log on specific portions of HTTP activity (e.g. HTTP request/response headers, socket level log output, or host resolver log output).

Non-novices can find more information on HTTP debugging in the "See also" section. 

Logging HTTP activity

Windows

1. Make sure Firefox is not running.

2. Open a command prompt, i.e. the "run" program. (Instructions for XP, Instructions for Vista.)

3. Copy-paste each of the following boldlines into the "run" prompt, hitting enter between them:

  • C:\> set NSPR_LOG_MODULES=nsHttp:5,nsSocketTransport:5,nsHostResolver:5
  • C:\> set NSPR_LOG_FILE=%TEMP%\log.txt
  • C:\> cd "Program Files\Mozilla Firefox"
  • Type the location of Firefox into the run line.  By default, Firefox installs to the following location:
    • For 32-bit Windows, C:\Program Files\Mozilla Firefox\> .\firefox.exe
    • For 64-bit Windows, C:\Program Files (x86)\Mozilla Firefox\> .\firefox.exe

4. Reproduce whatever problem you're trying to debug.

5. When the problem appears, exit Firefox and look for the generated log file: log.txt in your temp directory (you can type %TEMP% directly into Explorer's location bar to get to your temp directory).

Linux

1. Make sure Firefox is not running.

2. Open a new shell (example assumes bash compatible)

3. Copy-paste, into the shell, each of the following bold lines, hitting enter between each:

  • export NSPR_LOG_MODULES=nsHttp:5,nsSocketTransport:5,nsHostResolver:5
  • export NSPR_LOG_FILE=/tmp/log.txt
  • cd /path/to/firefox
  • ./firefox

4. Reproduce whatever problem you're trying to debug.

5. When the problem appears, exit Firefox and look for the generated log file: /tmp/log.txt

Mac OS X

1. Make sure Firefox is not running.

2. Run the Terminal application (open the Applications folder, then the Utilities folder)

3. Copy-paste each of the following bold lines into Terminal, hitting enter between each:

  • export NSPR_LOG_MODULES=nsHttp:5,nsSocketTransport:5,nsHostResolver:5
  • export NSPR_LOG_FILE=~/log.txt
  • Type the location of Firefox.
    • If it's on your desktop, cd ~/Desktop/Firefox.app/<wbr/>Contents/MacOS
    • If it's in the applications folder, cd /Applications/Firefox.app/<wbr/>Contents/MacOS
  • ./firefox-bin

4. Reproduce whatever problem you're trying to debug.

5. When the problem appears, exit Firefox and look for the generated log file log.txt in your home directory.

  • NOTE: the generated log file will have UNIX style line endings, so if you want to view it you will need to use an editor that can handled a UNIX style text file.

Excluding specific portions of HTTP activity

  • If you are only interested in logging HTTP request/response headers:
    • Option one: replace NSPR_LOG_MODULES=nsHttp:5 with NSPR_LOG_MODULES=nsHttp:3
    • Option two: There is also a handy extension for Firefox called Live HTTP Headers that can be used to capture only the HTTP request/response headers. It is a very handy tool in cases where you want to just peek at HTTP traffic.
  • If you are not interested in socket level log output (perhaps because you are debugging something that is accompanied by a lot of noise at this level):
    • Remove nsSocketTransport:5 
  • If you are not interested in host resolver log output (i.e., DNS queries):
    • Remove nsHostResolver:5

See also

  • There are similar options available to debug mailnews protocols. See this document for more info about mailnews troubleshooting.
  • On the windows platform, nightly Firefox builds have FTP logging enabled. (Don't ask why this is only the case for windows!) To enable FTP logging, just set NSPR_LOG_MODULES=nsFtp:5 (in older versions of Mozilla, you need to use nsFTPProtocol instead of nsFtp).
  • When the builtin logging facility of Mozilla is simply not sufficient, and you need a full fledged packet tracing tool, two free products are Ethereal and ngrep. They available for Windows and most flavors of UNIX (not including OSX last I checked), are rock solid, and offer enough features to help uncover any Mozilla networking problem.

Original Document Information

  • Author(s): Darin Fisher
  • Last Updated Date: January 5, 2007
  • Copyright Information: Portions of this content are © 1998–2007 by individual mozilla.org contributors; content available under a Creative Commons license | Details.

{{ languages( { "ja": "ja/HTTP_Logging" } ) }}

Revision Source

<p>This page contains instructions for how to use Mozilla's built-in logging facility to capture HTTP activity in Firefox.  The presentation is designed for people who are unfamiliar with Mozilla (or computers in general).  If you are such a person, simply look at the "Logging HTTP activity" section below.</p>
<p>If you are referring such a person to this page, please make clear to them where you want them to perform variations on these generic instructions.  The "Excluding specific portions of HTTP activity" section below provides some common variations for focusing the log on specific portions of HTTP activity (e.g. HTTP request/response headers, socket level log output, or host resolver log output).</p>
<p>Non-novices can find more information on HTTP debugging in the "See also" section. </p>
<h2>Logging HTTP activity</h2>
<h3>Windows</h3>
<p>1. Make sure Firefox is not running.</p>
<p>2. Open a command prompt, i.e. the "run" program. (<a class=" external" href="http://commandwindows.com/runline.htm" title="http://commandwindows.com/runline.htm">Instructions for XP</a>, <a class=" external" href="http://www.xp-vista.com/other/where-is-run-in-windows-vista" title="http://www.xp-vista.com/other/where-is-run-in-windows-vista">Instructions for Vista</a>.)</p>
<p>3. Copy-paste each of the following <strong><code><span style="font-family: Verdana,Tahoma,sans-serif;">bold</span></code></strong><code>lines into the "run" prompt, hitting enter between them:</code></p><code>
<ul> <li><strong>C<code>:\&gt; set NSPR_LOG_MODULES=nsHttp:5,nsSocketTransport:5,nsHostResolver:5</code></strong></li> <li><strong><code>C:\&gt; set NSPR_LOG_FILE=%TEMP%\log.txt</code></strong></li> <li><strong><code>C:\&gt; cd "Program Files\Mozilla Firefox"</code></strong></li> <li>Type the location of Firefox into the run line.  By default, Firefox installs to the following location: <ul> <li>For 32-bit Windows, <strong><code>C:\Program Files\Mozilla Firefox\&gt; .\firefox.exe</code></strong></li> <li>For 64-bit Windows, <strong><code>C:\Program Files (x86)\Mozilla Firefox\&gt; .\firefox.exe</code></strong></li> </ul> </li>
</ul>
<p>4. Reproduce whatever problem you're trying to debug.</p>
<p>5. When the problem appears, exit Firefox and look for the generated log file: <code>log.txt</code> in your temp directory (you can type <code>%TEMP%</code> directly into Explorer's location bar to get to your temp directory).</p>
<h3>Linux</h3>
<p>1. Make sure Firefox is not running.</p>
<p>2. Open a new shell (example assumes bash compatible)</p>
<p>3. Copy-paste, into the shell, each of the following <strong><code><span style="font-family: Verdana,Tahoma,sans-serif;">bold</span></code></strong> lines, hitting enter between each:</p>
<ul> <li><strong><code>export NSPR_LOG_MODULES=nsHttp:5,nsSocketTransport:5,nsHostResolver:5</code></strong></li> <li><strong><code>export NSPR_LOG_FILE=/tmp/log.txt</code></strong></li> <li><strong><code>cd /path/to/firefox</code></strong></li> <li><strong><code>./firefox</code></strong></li>
</ul>
<p>4. Reproduce whatever problem you're trying to debug.</p>
<p>5. When the problem appears, exit Firefox and look for the generated log file: /tmp/log.txt</p>
<h3>Mac OS X</h3>
<p>1. Make sure Firefox is not running.</p>
<p>2. Run the Terminal application (open the Applications folder, then the Utilities folder)</p>
<p>3. Copy-paste each of the following <strong><code><span style="font-family: Verdana,Tahoma,sans-serif;">bold</span></code></strong> lines into Terminal, hitting enter between each:</p>
<ul> <li><strong><code>export NSPR_LOG_MODULES=nsHttp:5,nsSocketTransport:5,nsHostResolver:5</code></strong></li> <li><strong><code>export NSPR_LOG_FILE=~/log.txt</code></strong></li> <li>Type the location of Firefox. <ul> <li>If it's on your desktop, <strong><code>cd ~/Desktop/Firefox.app/</code>&lt;wbr/&gt;<code>Contents/MacOS</code></strong></li> <li>If it's in the applications folder, <strong><code>cd /Applications/Firefox.app/</code>&lt;wbr/&gt;<code>Contents/MacOS</code></strong></li> </ul> </li> <li><strong><code>./firefox-bin</code></strong></li>
</ul>
<p>4. Reproduce whatever problem you're trying to debug.</p>
<p>5. When the problem appears, exit Firefox and look for the generated log file <code>log.txt</code> in your home directory.</p>
<ul> <li>NOTE: the generated log file will have UNIX style line endings, so if you want to view it you will need to use an editor that can handled a UNIX style text file.</li>
</ul>
<h2>Excluding specific portions of HTTP activity</h2>
<ul> <li>If you are only interested in logging HTTP request/response headers: <ul> <li>Option one: replace <strong><code>NSPR_LOG_MODULES=nsHttp:5</code></strong> with <strong><code style="color: rgb(37, 34, 29); font-weight: inherit; ">NSPR_LOG_MODULES=nsHttp:3</code></strong></li> <li>Option two: There is also a handy extension for Firefox called <a class="link-https" href="https://addons.mozilla.org/firefox/addon/3829">Live HTTP Headers</a> that can be used to capture only the HTTP request/response headers. It is a very handy tool in cases where you want to just peek at HTTP traffic.</li> </ul> </li> <li>If you are not interested in socket level log output (perhaps because you are debugging something that is accompanied by a lot of noise at this level): <ul> <li><code style="color: rgb(37, 34, 29); font-weight: inherit; ">Remove </code><strong><code style="color: rgb(37, 34, 29); font-weight: inherit; ">nsSocketTransport:5</code> </strong></li> </ul> </li> <li>If you are not interested in host resolver log output (i.e., DNS queries): <ul> <li><code style="color: rgb(37, 34, 29); font-weight: inherit; ">Remove </code><strong><code style="color: rgb(37, 34, 29); font-weight: inherit; ">nsHostResolver:5</code></strong></li> </ul> </li>
</ul>
<h2>See also</h2>
<ul style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.7em; margin-left: 25px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "> <li style="margin-bottom: 0.25em; ">There are similar options available to debug mailnews protocols. See <a class="external" href="http://www.mozilla.org/quality/mailnews/mail-troubleshoot.html">this document</a> for more info about mailnews troubleshooting.</li> <li style="margin-bottom: 0.25em; ">On the windows platform, nightly Firefox builds have FTP logging enabled. (Don't ask why this is only the case for windows!) To enable FTP logging, just set <code style="color: rgb(37, 34, 29); font-weight: inherit; ">NSPR_LOG_MODULES=nsFtp:5</code> (in older versions of Mozilla, you need to use <code style="color: rgb(37, 34, 29); font-weight: inherit; ">nsFTPProtocol</code> instead of <code style="color: rgb(37, 34, 29); font-weight: inherit; ">nsFtp</code>).</li> <li style="margin-bottom: 0.25em; ">When the builtin logging facility of Mozilla is simply not sufficient, and you need a full fledged packet tracing tool, two free products are <a class="external" href="http://www.ethereal.com/">Ethereal</a> and <a class="external" href="http://ngrep.sourceforge.net/">ngrep</a>. They available for Windows and most flavors of UNIX (not including OSX last I checked), are rock solid, and offer enough features to help uncover any Mozilla networking problem.</li>
</ul>
<div class="originaldocinfo">
<h2 name="Original_Document_Information">Original Document Information</h2>
<ul> <li>Author(s): <a class="link-mailto" href="mailto:darin@meer.net">Darin Fisher</a></li> <li>Last Updated Date: January 5, 2007</li> <li>Copyright Information: Portions of this content are © 1998–2007 by individual mozilla.org contributors; content available under a Creative Commons license | <a class="external" href="http://www.mozilla.org/foundation/licensing/website-content.html">Details</a>.</li>
</ul>
</div>
<p>{{ languages( { "ja": "ja/HTTP_Logging" } ) }}</p></code>
Revert to this revision