Home > Net >  How do I find the logs of Firefox?
How do I find the logs of Firefox?

Time:09-18

While browsing the Firefox source code, I see that a lot of logs are present. I'd like to find them on runtime to help me understand and debug something.

For example, when taking a look at nsHttpConnection.cpp, Here's what I can find :

  ...
  LOG(("restarting transaction @%p\n", this));
  mTunnelProvider = nullptr;
  ...

Where did the LOG lines go ? How do I find the log file containing all the logs generated by Firefox ?

CodePudding user response:

In the case of the file nsHttpConnection.cpp, the LOG() functions are macros defined in HttpLog.h.

here's an excerpt :

#define LOG1(args) \
  MOZ_LOG(mozilla::net::gHttpLog, mozilla::LogLevel::Error, args)

You can see them as shortcuts for the more complete MOZ_LOG functions.

  • LOG1() -> Error
  • LOG2() -> Warning
  • LOG3() -> Info
  • LOG() = LOG4() -> Debug
  • LOG5() -> Verbose

If you want to get the logs for the nsHttp module, you can set 2 environment variables, and then run firefox :

set MOZ_LOG=nsHttp:5
set MOZ_LOG_FILE=http.log
firefox

or run firefox with the command line parameters :

firefox -MOZ_LOG=nsHttp:5 -MOZ_LOG_FILE=nsHttp.log

This enables Verbose level information (and higher) and places all output in the file nsHttp.log.

The MOZ_LOG variable is composed of as <module>:level.

You can also use a more general module all to include them all.

i.e. to log all Error level informations in the file all.log:

firefox -MOZ_LOG=all:1 -MOZ_LOG_FILE=all.log

For more information on how the MOZ_LOG variable is configured, you can take a look at prlog.h

  • Related