MailNews:Logging: Difference between revisions
m (→Introduction: improve wording) |
m (→Setting a Preference: nits) |
||
| Line 41: | Line 41: | ||
# do Settings > General | # do Settings > General | ||
# in the search field type <code>config editor</code> | # in the search field type <code>config editor</code> | ||
# click Config Editor | # click <code>Config Editor</code> in the search results | ||
# in the search field paste or type the preference name, for example mailnews.pop3.loglevel | # in the search field paste or type the preference name, for example <code>mailnews.pop3.loglevel</code> | ||
# if you are presented with choices of Boolean, Number, String | # if you are presented with choices of Boolean, Number, String | ||
## choose Boolean for true or false settings, otherwise choose Number | |||
## click the <code>+</code> (plus sign) to add the preference | |||
# change the preferences's value to the desired logging value | # change the preferences's value to the desired logging value | ||
#* for numeric preferences click the pencil icon, change the value, then click the check mark | #* for numeric preferences click the pencil icon, change the value, then click the check mark | ||
Revision as of 11:04, 14 January 2023
Logs provide data to help developers and triagers understand what is causing an issue. Please provide a log file when requested. If you have difficulty or questions, please ask for help.
Introduction
Logging in recent years has evolved in:
- where logging is enabled - possibilities include command line, and Thunderbird preferences
- location of log data - possibilities include logging to a file, and logging to the Error Console
Also, we have two types of logging:
- Gecko logging, which uses module names
- Thunderbird logging
Thunderbird Logging
Modern logging is specified via Thunderbird preferences and output goes to the Error Console. Thunderbird logging is disabled by default. Unless otherwise specified, logging is enabled by setting a preference to true. Unless otherwise specified, logging output goes to the Error Console, accessible at Tools > Developer > Error Console.
Thunderbird Logging Types
- Calendar/Calendar logging
- Chat -
purple.debug.loglevelset to [1]- 0 Show all libpurple messages (PURPLE_DEBUG_ALL)
- 1 Very verbose (PURPLE_DEBUG_MISC)
- 2 Verbose (PURPLE_DEBUG_INFO)
- 3 Show warnings (PURPLE_DEBUG_WARNING)
- 4 Show errors (PURPLE_DEBUG_ERROR)
- 5 Show only fatal errors (PURPLE_DEBUG_FATAL)
- Chat Off-The-Record (OTR) protocol for exchanging encrypted chat messages -
chat.otr.traceboolean preference - Gloda Indexing (global search) activity to Error Console
- ldap -
mailnews.ldap.loglevelset toAll - NNTP -
mailnews.nntp.loglevelset toAll - pop3 -
mailnews.pop3.loglevelset toAll - smtp -
mailnews.smtp.loglevelset toAll
Setting a Preference
To configure logging via a Thunderbird Preference, you must create a hidden Thunderbird preference, not an environment variable. In Thunderbird :
- do Settings > General
- in the search field type
config editor - click
Config Editorin the search results - in the search field paste or type the preference name, for example
mailnews.pop3.loglevel - if you are presented with choices of Boolean, Number, String
- choose Boolean for true or false settings, otherwise choose Number
- click the
+(plus sign) to add the preference
- change the preferences's value to the desired logging value
- for numeric preferences click the pencil icon, change the value, then click the check mark
- for boolean preferences click the double headed arror to switch between
trueandfalse
To delete a preference, click the trash can.
It is not necessary to restart Thunderbird - logging starts immediately. You can view the output in the Error Console.
Gecko Logging
Gecko logging is the classic method of getting log data. Gecko logging is enabled via preferences (not discussed in this document) or command line.
Thunderbird gets its "module" logging capabilities from Firefox core aka Gecko. Gecko logging capabilities are thoroughly documented in this excellent reference.
Thunderbird Module Names
All names are CASE SENSITIVE. Some relate to specific mail protocols.
- AbOutlookDirectory (before Thunderbird version 59: nsAbOutlookDirectoryLog)
- AbWinHelper (before Thunderbird version 59: nsAbWinHelperLog)
- BayesianFilter
- CMS (for S/MIME)
- Filters
- IMAP
- IMAP_CS (for CONDSTORE)
- IMAP_KW (for keyword (tag) processing)
- IMAPAutoSync (before Thunderbird version 59: ImapAutoSync)
- IMAPCache (for IMAP caching of messages in no-sync folders)
- IMAPOffline (before Thunderbird version 59: IMAPOFFLINE)
- Import (before Thunderbird version 59: IMPORT)
- ldap (After Thunderbird 90 use Thunderbird logging)
- Mailbox (before Thunderbird version 59: MAILBOX)
- MailDirStore
- MAPI
- MAPIAddressBook
- MIME
- MsgBiff
- MsgCompose (before Thunderbird version 59: msgcompose)
- MsgCopyService (3.3a4 nightly builds starting 5/2/2011)
- MsgDB (level 1=opens/closes, level 5 lists open db's on close, number of msg hdrs in use) (before Thunderbird version 59: MSGDB)
- MsgPurge
- NNTP (After Thunderbird 95 use Thunderbird logging)
- pop3 (After Thunderbird 98 use Thunderbird logging)
- smtp (After Thunderbird 90 use "Thunderbird logging)
Notes:
- The above list is fairly complete. The full, current definitive list of modules is in this searchfox query.
- Potentially useful core Gecko modules not listed above: nsHostResolver (for DNS), GetAddrInfo (for DNS), nsSocketTransport (basic networking), negotiateauth (authentication)
- In version 59, bug 1353919 changed these options to be mixed case. The old, inconsistent case options are shown above in parenthesis.
- [1] To expose timestamp in the Error Console, click the gear icon in top-right of the Error Console, turn on "Show Timestamps".
- Deprecated:
- Movemail
- AbOutlookDirFactory (before Thunderbird version 59: nsAbOutlookDirFactoryLog)
- WABAddressBook
Environment Variables to set
NOTE - do not use this section for ldap, nntp, pop3 and smtp. They are configured per Thunderbird logging.
Two variables must be set. (Except for logging of ldap, nntp, pop3 and smtp, which are configured in Thunderbird settings and log to the Error Console - per instructions above. So you may ignore this section and the next for these protocols.) You can set these variables globally as system environment variables (find instructions for your OS), or as local environment variables in a batch file/script (described below), or just on the command line.
- MOZ_LOG - CASE SENSITIVE module name and log level separated by colon, multiple modules separated by comma, and additional options:
- Example module and loglevel: IMAP:5,timestamp
- ,timestamp adds a timestamp to all log lines - generally recommended. required for all timeouts and issues which need to be correlated to an action at a given time of day (as of 2009-05-13 3.0b3pre builds)
- optional, not recommended (because it makes logging slower and affects your performance) ,sync : Buffering in log writing is disabled that so latest log data can be seen by tailing or copying the log file.
- MOZ_LOG_FILE - Path (with name) to the log file
- If MOZ_LOG_FILE is not set, then the output will be logged to the console where the application was launched.
- Since Thunderbird 70, the .moz_log extension will be added to the file name
Note:
- The log file is written over every time you re-launch the Mozilla application.
- If you are running multiple Mozilla applications (Firefox and Thunderbird) they may stomp on each other in the log, or even wipe out the others log entries.
- You must have write access to the directory of the log file.
Logging level
NOTE - do not use this section for ldap, nntp, pop3 and smtp. They are configured per Thunderbird logging.
The number in MOZ_LOG specifies the level of logging to be used. A lower number reduces the amount of information being logged. Use "5" unless requested otherwise.
- 0 = Disabled /* Indicates logging is disabled. This should not be used directly in code. */
- 1 = Error /* An error occurred, generally something you would consider asserting in a debug build.*/
- 2 = Warning /* A warning often indicates an unexpected state. */
- 3 = Info /* An informational message, often indicates the current program state. */
- 4 = Debug /* A debug message, useful for debugging but too verbose to be turned on normally. */
- 5 = Verbose /* A message that will be printed a lot, useful for debugging program flow and will probably impact performance. */
Some modules may not work exactly according to the log levels noted above. Very few modules actually have more than one logging level
Generating a Gecko Log
NOTE - do not use this section for ldap, nntp, pop3 and smtp. They are configured in Thunderbird Settings, and log to the Thunderbird Error Console. Please refer to module options.
Windows
Create a batch file by copying the lines below and paste them into the notepad application, and save the file as "create_imap_log.bat". Variables MOZ_LOG and MOZ_LOG_file must not contain quotation marks.
set MOZ_LOG=IMAP:5,timestamp set MOZ_LOG_FILE=%USERPROFILE%\Desktop\imap.log "%ProgramFiles(x86)%\Mozilla Thunderbird\thunderbird.exe"
- To log a different module, replace "IMAP" with e.g. "MIME" In the above instructions
- XP and Vista users should specify %ProgramFiles% instead of %ProgramFiles(x86)% (which is for Windows 7) - assuming Thunderbird was installed to it's default location.
- On versions with User Account Control such as Vista and Windows 7, the batch file must be run with administrator privileges. Right click on the batch file and select "Run as administrator". Otherwise the log file will not be created and no UAC warnings will be generated.
Now run the batch file. The example puts the log file on your desktop:
You can set up the batch file to be run using of these methods: double click the batch file, create a shortcut, add it to start menu, from a command window prompt, or from the start>run dialog.
Logging commands can also typed directly in the command prompt instead of running a batch file. On Windows 2000, XP, 2003 Server: Start>Programs>Accessories>Command Prompt. On later windows versions, you may type "cmd" and press enter in the launch dialog of the Start button.
Mac OS X
To generate an IMAP protocol log, create a text file that contains the desired commands in a text editor such as BBEdit:
#!/bin/sh export MOZ_LOG=IMAP:5,timestamp export MOZ_LOG_FILE=$HOME/Desktop/imap.log /Applications/Thunderbird.app/Contents/MacOS/thunderbird-bin &
If on 10.5 change the last line to arch -arch i386 /Applications/Thunderbird.app/Contents/MacOS/thunderbird-bin &
Save this file with a filename ending in .command, add execute permission by typing "chmod a+x filename" in a Terminal window, then double-click it.
To get a log for another protocol, replace "imap" with e.g. "MIME" in the above instructions.
Alternatively, you can setup a file so that the protocol tracing will always be in effect. To do this open a Terminal window, cd into the .MacOSX directory under your login directory and create a file named environment.plist containing the following. Non-unix users can use the "pico" editor which I think is available on OS X by default:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>MOZ_LOG_FILE</key> <string>/tmp/imaptrace.txt</string> <key>MOZ_LOG</key> <string>IMAP:5</string> </dict> </plist>
Note, line starting with "<!DOCTYPE" should be oneline all the way to "dtd", but I'm not sure if that makes a difference.
Linux/unix
To generate an IMAP protocol log, run the following commands before running the application from the command line:
# For bash shell (the default shell on most GNU/Linux systems): export MOZ_LOG=IMAP:5,timestamp export MOZ_LOG_FILE=/tmp/imap.log
# For tcsh / csh (which is not as common): setenv MOZ_LOG IMAP:5 setenv MOZ_LOG_FILE /tmp/imap.log
To get a log for another protocol, replace "IMAP" with e.g. "MIME" in the above instructions.
Missing Log File
If your log file is empty or missing, review this document again, and check for these common problems:
- Are you logging ldap, nntp, pop3, or smtp? You must use Thunderbird logging, not an environment variable.
- Do you have write access to the directory specified in MOZ_LOG_FILE?
- Did you shut down the mailnews application? (the log file is buffered in memory)
- Did you restart your mailnews application, and wipe out the log of the session you wanted to debug? (every restart wipes out the previous log)
- If you used a batch file on Windows, is the batch file set to run with administrator privileges?
- Do your log variables contain quotation marks or other invalid characters?
- Are your log module names correctly CASE SENSITIVE? (meaning mixed case, or camel case which is not all upper case, nor all lower case)
NSPR Logging Options
NSPR also has logging. Miscellaneous NSPR Reference (logging).
Enhancement Ideas
- bug 492620 - better, easier logging/diagnostics for Thunderbird [meta]
- bug 193873 - Add Mozilla logging to UI / Thunderbird:Logging_UI
- bug 697522 - precise logging of message filter runs and actions
Logging prior to Thunderbird 55.0a1 / SeaMonkey 2.52a1
Around April 5, 2017, via bug 1222244 and blockers of bug 1219461, changes were merged to the Mozilla trunk which impacted logging functionality. Prior to these changes, the variable names used to configure logging were NSPR_LOG_MODULES and NSPR_LOG_FILE rather than MOZ_LOG and MOZ_LOG_FILE. If you are working with an older version, use the old variable names.
In addition, some log module names changed. The old names are documented below, but will eventually be removed (along with this section) when enough time has past that it is no longer necessary for most people to debug older versions of the applications. Of course, the obsolete documentation will remain accessible in the history of this page.
Note that log module names are CASE SENSITIVE.