MailNews:Logging: Difference between revisions
m (add timestamp to example scripts) |
(Update for change from NSPR_LOG_MODULES -> MOZ_LOG) |
||
Line 4: | Line 4: | ||
__TOC__ | __TOC__ | ||
== Logging prior to Thunderbird 55.0a1 / SeaMonkey 2.52a1 == | |||
On around April 6, 2017, 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 in the current logging implementation but were previously case-insensitive. | |||
== Main module options within MailNews == | == Main module options within MailNews == | ||
Line 9: | Line 17: | ||
MailNews applications (SeaMonkey/Thunderbird) allow these modules/protocols in both debug and release builds: | MailNews applications (SeaMonkey/Thunderbird) allow these modules/protocols in both debug and release builds: | ||
* | * BayesianFilter | ||
* | * IMAP | ||
* IMAPOFFLINE | |||
* ldap | * ldap | ||
* | * MAILBOX | ||
* | * MailDirStore | ||
* | * MIME | ||
* | * MsgBiff | ||
* | * msgcompose | ||
* MsgCopyService <small>(3.3a4 nightly builds starting 5/2/2011)</small> | |||
* MSGDB <small> (level 1=opens/closes, level 5 lists open db's on close, number of msg hdrs in use)</small> | |||
* MsgPurge | |||
* NNTP | |||
* POP3 | |||
* SMTP | |||
([[MailNews:Logging#Other_Protocol_Logging_options_within_MailNews|Other options below]]) | ([[MailNews:Logging#Other_Protocol_Logging_options_within_MailNews|Other options below]]) | ||
Line 24: | Line 39: | ||
Two variables must be set. These can be as (global/system) environment variables. Or, what we document here, as variables in a batch file/script or on the command line: | Two variables must be set. These can be as (global/system) environment variables. Or, what we document here, as variables in a batch file/script or on the command line: | ||
# ''' | # '''MOZ_LOG''' - Module name and log level separated by colon, multiple modules separated by comma, and additional options: | ||
#* Example module and loglevel with timestamp: "ldap:5,smtp:3,timestamp" | #* Example module and loglevel with timestamp: "ldap:5,smtp:3,timestamp" | ||
#* Example module and loglevel: "imap:5" | #* Example module and loglevel: "imap:5" | ||
#* recommended (optional) '''",timestamp"''' : a timestamp string is added to all log entries - recommended for all timeouts and issues which need to be correlated to an action at a given time of day <small>(as of 2009-05-13 3.0b3pre builds)</small> | #* recommended (optional) '''",timestamp"''' : a timestamp string is added to all log entries - recommended for all timeouts and issues which need to be correlated to an action at a given time of day <small>(as of 2009-05-13 3.0b3pre builds)</small> | ||
#* optional ",sync" : Buffering in log writing is disabled, so latest log data can be seen by ad-hoc copy of log file | #* optional ",sync" : Buffering in log writing is disabled, so latest log data can be seen by ad-hoc copy of log file | ||
# ''' | # '''MOZ_LOG_FILE''' - Path to the log file | ||
#* If | #* If MOZ_LOG_FILE is not set, then the output will be logged to the console where the application was launched. | ||
Note: | Note: | ||
Line 38: | Line 53: | ||
=== Logging level === | === Logging level === | ||
The number in | 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. | ||
* PR_LOG_NONE = 0, /* nothing */ | * PR_LOG_NONE = 0, /* nothing */ | ||
Line 55: | Line 70: | ||
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". | 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". | ||
set | set MOZ_LOG=imap:5,timestamp | ||
set | set MOZ_LOG_FILE=%USERPROFILE%\Desktop\imap.log | ||
"%ProgramFiles(x86)%\Mozilla Thunderbird\thunderbird.exe" | "%ProgramFiles(x86)%\Mozilla Thunderbird\thunderbird.exe" | ||
Line 74: | Line 89: | ||
#!/bin/sh | #!/bin/sh | ||
export | export MOZ_LOG=imap:5,timestamp | ||
export | export MOZ_LOG_FILE=$HOME/imap.log | ||
/Applications/Thunderbird.app/Contents/MacOS/thunderbird-bin & | /Applications/Thunderbird.app/Contents/MacOS/thunderbird-bin & | ||
if on 10.5 change the above line to arch -arch i386 /Applications/Thunderbird.app/Contents/MacOS/thunderbird-bin & | if on 10.5 change the above line to arch -arch i386 /Applications/Thunderbird.app/Contents/MacOS/thunderbird-bin & | ||
Line 88: | Line 103: | ||
<plist version="1.0"> | <plist version="1.0"> | ||
<dict> | <dict> | ||
<key> | <key>MOZ_LOG_FILE</key> | ||
<string>/tmp/imaptrace.txt</string> | <string>/tmp/imaptrace.txt</string> | ||
<key> | <key>MOZ_LOG</key> | ||
<string>IMAP:5</string> | <string>IMAP:5</string> | ||
</dict> | </dict> | ||
Line 102: | Line 117: | ||
# For bash shell (the default shell on most GNU/Linux systems): | # For bash shell (the default shell on most GNU/Linux systems): | ||
export | export MOZ_LOG=imap:5,timestamp | ||
export | export MOZ_LOG_FILE=/tmp/imap.log | ||
# For tcsh / csh (which is not as common): | # For tcsh / csh (which is not as common): | ||
setenv | setenv MOZ_LOG imap:5 | ||
setenv | setenv MOZ_LOG_FILE /tmp/imap.log | ||
To get a log for another protocol, replace "imap" with e.g. "smtp" or "pop3" in the above instructions. | To get a log for another protocol, replace "imap" with e.g. "smtp" or "pop3" in the above instructions. | ||
Line 127: | Line 142: | ||
The following modules may or may not be available in release builds, but are available in debug builds: | The following modules may or may not be available in release builds, but are available in debug builds: | ||
* | * APPLEMAILIMPORTLOG | ||
* DockCounts <small>(for logging issues with the mac dock unread count, 3.04 and above; I can't find any evidence of this still existing as of May 15, 2017, though I don't know when it was removed)</small> | |||
* DockCounts (for logging issues with the mac dock unread count, 3.04 and above) | * gssapi <small>(I can't find any evidence of this still existing as of May 15, 2017, though I don't know when it was removed)</small> | ||
* gssapi | * ImapAutoSync | ||
* | * IMPORT | ||
* | * ldapautocomplete <small>(I can't find any evidence of this still existing as of May 15, 2017, though I don't know when it was removed)</small> | ||
* ldapautocomplete | * MAPI | ||
* | * Movemail | ||
* | |||
* negotiateauth | * negotiateauth | ||
* nsaboutlookcardlog | * nsaboutlookcardlog <small>(I can't find any evidence of this still existing as of May 15, 2017, though I don't know when it was removed)</small> | ||
* | * nsAbOutlookDirectoryLog | ||
* | * nsAbOutlookDirFactoryLog | ||
* nswabaddressbook | * nsAbWinHelperLog | ||
* nsWabAddressBookLog <small>(This may have previously been "nswabaddressbook" in the code, or that may have just been an error in this Wiki page)</small> | |||
== Other Important MailNews logging == | == Other Important MailNews logging == |
Revision as of 00:01, 16 May 2017
Mailnews logs help developers understand what is causing an issue. Please enable Thunderbird to write extra information to a log file, by setting two environment variables before running a MailNews application.
Logging prior to Thunderbird 55.0a1 / SeaMonkey 2.52a1
On around April 6, 2017, 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 in the current logging implementation but were previously case-insensitive.
Main module options within MailNews
MailNews applications (SeaMonkey/Thunderbird) allow these modules/protocols in both debug and release builds:
- BayesianFilter
- IMAP
- IMAPOFFLINE
- ldap
- MAILBOX
- MailDirStore
- MIME
- MsgBiff
- 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)
- MsgPurge
- NNTP
- POP3
- SMTP
Environment Variables to set
Two variables must be set. These can be as (global/system) environment variables. Or, what we document here, as variables in a batch file/script or on the command line:
- MOZ_LOG - Module name and log level separated by colon, multiple modules separated by comma, and additional options:
- Example module and loglevel with timestamp: "ldap:5,smtp:3,timestamp"
- Example module and loglevel: "imap:5"
- recommended (optional) ",timestamp" : a timestamp string is added to all log entries - recommended 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 ",sync" : Buffering in log writing is disabled, so latest log data can be seen by ad-hoc copy of log file
- MOZ_LOG_FILE - Path 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.
Note:
- The log is written over every time you re-launch the mozilla application.
- You must have write access to the directory of the log file.
Logging level
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.
- PR_LOG_NONE = 0, /* nothing */
- PR_LOG_ALWAYS = 1, /* always printed */
- PR_LOG_ERROR = 2, /* error messages */
- PR_LOG_WARNING = 3, /* warning messages */
- PR_LOG_DEBUG = 4, /* debug messages */
- 5 (recommended)
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 Protocol Log
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".
set MOZ_LOG=imap:5,timestamp set MOZ_LOG_FILE=%USERPROFILE%\Desktop\imap.log "%ProgramFiles(x86)%\Mozilla Thunderbird\thunderbird.exe"
- To log another protocol, replace "imap" with e.g. "smtp" or "pop3" 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/imap.log /Applications/Thunderbird.app/Contents/MacOS/thunderbird-bin & if on 10.5 change the above 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. "smtp" or "pop3" 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. "smtp" or "pop3" 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:
- Do you have write access to the directory specified?
- 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?
Reference Documents
Other Protocol Logging options within MailNews
The following modules may or may not be available in release builds, but are available in debug builds:
- APPLEMAILIMPORTLOG
- DockCounts (for logging issues with the mac dock unread count, 3.04 and above; I can't find any evidence of this still existing as of May 15, 2017, though I don't know when it was removed)
- gssapi (I can't find any evidence of this still existing as of May 15, 2017, though I don't know when it was removed)
- ImapAutoSync
- IMPORT
- ldapautocomplete (I can't find any evidence of this still existing as of May 15, 2017, though I don't know when it was removed)
- MAPI
- Movemail
- negotiateauth
- nsaboutlookcardlog (I can't find any evidence of this still existing as of May 15, 2017, though I don't know when it was removed)
- nsAbOutlookDirectoryLog
- nsAbOutlookDirFactoryLog
- nsAbWinHelperLog
- nsWabAddressBookLog (This may have previously been "nswabaddressbook" in the code, or that may have just been an error in this Wiki page)
Other Important MailNews logging
- Log Gloda activity to console(Thunderbird only) Debugging Gloda
- Calendar/Lightning logging
Other Useful NSPR Logging Options
The following modules may or may not be available in release builds, but are available in debug builds:
- nsDragService
The following modules are not owned by Mail&News, but useful for problem analysis of Mail&News.
- timestamp NSPR Reference, Chapter 26 Logging (Timestamp is added to NSPR log)
- nsHostResolver, nsSocketTransport HTTP_Logging (DNS lookup, Socket log)
- DOMLeak, DocumentLeak, nsDocShellLeak Leak Gauge (Internal load of mail can be traced)
Logging Tools
- Log Parsing - Logs can be difficult to parse because of their size. Andrew Sutherland has written a parsing script in Python for analyzing these logs. The script may need to be tweaked to suit your needs. There is more information at this bug comment.
- TBTracer addon by Thundersomething author "derdoc"
- loghelper addon by jtcranmer
Enhancement Ideas
- bug 492620 - better, easier logging/diagnostics for Thunderbird [meta]
- bug 193873 - Add Mozilla logging to UI / Thunderbird:Logging_UI