Table of contents
Jump down to the "Logging HTTP Activity" section↓ for instructions on using Mozilla's built-in logging facility to capture HTTP activity in Firefox, written for people who are unfamiliar with Mozilla (or computers in general).
For more experienced users, see the "Excluding specific portions of HTTP activity" section ↓ for instructions on focusing the log on specific portions of HTTP activity (e.g. HTTP request/response headers, socket level log output, or host resolver log output). If you are referring a novice to this page, please make clear to them where you want them to perform these variations on the generic instructions.
The "See also" section ↓ contains non-novice information on HTTP debugging.
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.txtC:\> 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
- For 32-bit Windows,
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:5export NSPR_LOG_FILE=/tmp/log.txtcd /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:5export NSPR_LOG_FILE=~/Desktop/log.txt- Type the location of Firefox.
- If it's on your Desktop,
cd ~/Desktop/Firefox.app/Contents/MacOS - If it's in the Applications folder,
cd /Applications/Firefox.app/Contents/MacOS
- If it's on your Desktop,
./firefox-bin
4. Reproduce whatever problem you're trying to debug.
5. When the problem appears, quit Firefox and look for the generated log file log.txt on your Desktop.
- 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:5withNSPR_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.
- Option one: replace
- 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):
RemovensSocketTransport:5
- If you are not interested in host resolver log output (i.e., DNS queries):
RemovensHostResolver: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 usensFTPProtocolinstead ofnsFtp). - When the builtin logging facility of Mozilla is simply not sufficient, and you need a full fledged packet tracing tool, two free products are Wireshark and ngrep. They are available for Windows and most flavors of UNIX (including Linux and OS X), 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.

