Darin Fisher / darin at meer dot net
June 16, 2004
Enabling HTTP logging:
Make sure Mozilla is not running (be sure that Quick Launch is disabled). Then open a DOS prompt, and type the following (this example assumes that you have installed Mozilla in the default location):C:\> set NSPR_LOG_MODULES=nsHttp:5,nsSocketTransport:5,nsHostResolver:5 C:\> set NSPR_LOG_FILE=C:\log.txt C:\> cd "Program Files\mozilla.org\Mozilla" C:\Program Files\mozilla.org\Mozilla\> .\mozilla.exeNow reproduce whatever problem you're trying to debug, and when you are done exit Mozilla and look for the generated log file: C:\log.txt
Make sure Mozilla is not running. Then open a new shell (example assumes bash compatible), and type the following:bash$ export NSPR_LOG_MODULES=nsHttp:5,nsSocketTransport:5,nsHostResolver:5 bash$ export NSPR_LOG_FILE=/tmp/log.txt bash$ /path/to/mozilla/mozillaNow reproduce whatever problem you're trying to debug, and when you are done exit Mozilla and look for the generated log file: /tmp/log.txt
Make sure Mozilla is not running. Then run the Terminal application (found under the Utilities application group), and type the following commands (this example assumes that you have installed Mozilla on your desktop and that you are using the default OSX command shell, tcsh):[mybox:~] user% setenv NSPR_LOG_MODULES nsHttp:5,nsSocketTransport:5,nsHostResolver:5 [mybox:~] user% setenv NSPR_LOG_FILE ~/log.txt [mybox:~] user% cd Desktop/Mozilla.app/Contents/MacOS [mybox:Mozilla.app/Contents/MacOS] user% ./mozilla-bin
If you are using Mac OSX 10.3 or later, then you're most likely using the bash shell instead of tcsh. In that case replace
Now reproduce whatever problem you're trying to debug, and when you are done exit Mozilla 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.
- If you were only interested in logging HTTP request/response headers, then set "NSPR_LOG_MODULES=nsHttp:3" only.
- nsSocketTransport:5 can be removed if you are not interested in socket level log output (there can be a lot of noise from logging at this level depending on what you are trying to debug).
- nsHostResolver:5 can be removed if you are not interested in host resolver log output (i.e., DNS queries).
- There is also a handy extension for Mozilla called livehttpheaders 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.
- Finally, there are times when the builtin logging facility of Mozilla is simply not sufficient, and one must resort to a full fledged packet tracing tool. Ethereal and ngrep are two excellent tools available for Windows and most flavors of UNIX (not including OSX last I checked). Commercially available packet tracers may offer better features, but for the most part these freely available tracers are rock solid and offer enough features to help uncover any Mozilla networking problem.
- There are similar options available to debug mailnews protocols. See this document for more info about mailnews troubleshooting.
- On the windows platform, nightly mozilla 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").