Using log4j to Configure mailboxd Logging
|This article applies to the following ZCS versions.|
The Zimbra server uses log4j, a Java logging package, as the log manager for mailboxd. By default, the Zimbra server has log4j configured to log to the local file system. You can configure log4j to direct output to a variety of other locations. For more information on log4j, see the Apache log4j documentation.
This article outlines how to use log4j to configure log4j categories, log output, logging levels.
Note: This article is only relevant to logging for mailboxd. For information on other Zimbra log files, see Log Files.
log4j Configuration File
Errors, warnings and other logging events are logged by category. For example, an IMAP error will be logged to the log4j.logger.zimbra.imap sub-category. The category settings in log4j are stored in a configuration file. This file is located at /opt/zimbra/conf/log4j.properties. To configure logging output and logging levels, you must change a category in the log4j configuration file. Changes to the configuration file will take effect immediately.
To make permanent changes to the configuration file, make changes to /opt/zimbra/conf/log4j.properties.in, and either run zmmtaconfig mailboxd or restart the server using zmcontrol.
Enabling DEBUG in the appropriate sub-category can help you identify a problem. If you do not know what sub-category to enable, you can enable DEBUG in log4j.logger.zimbra, however this will generate logging events for every single subcategory. This is a very large amount of logging events and can take a long time to read through. For this reason, it is always advisable to enable DEBUG or another logging level in a specific sub-category. To enable logging for a specific category, add the following to the end of the log4j configuration file:
For example, the following enables DEBUG level logging for the zimbra.mailbox category:
Note: Review the configuration file to see if the category you are enabling is already listed. If a category is listed twice, and both instances have the same appender, it will log each event twice.
Predefined log4j Categories in ZCS
The following table contains a list of log4j categories which are predefined in the Zimbra Collaboration Suite.
Note: You can also find information on predefined log4j categories in zmprov help log.
|log4j.logger.zimbra||Parent logger category. Records log events for all of the following child categories. By default, this category is set to the INFO log level.|
|Sub-categories of log4j.logger.zimbra||Description|
|zimbra.backup||Backup and restore|
|zimbra.cache||In-memory cache operations|
|zimbra.dbconn||Database connection tracing|
|zimbra.extensions||Server extension loading|
|zimbra.im||Instant messaging operations|
|zimbra.imap||IMAP protocol operations|
|zimbra.io||File system operations|
|zimbra.lmtp||LMTP operations (incoming mail)|
|zimbra.mailbox||General mailbox operations|
|zimbra.op||Changes to the mailbox state|
|zimbra.pop||POP protocol operations|
|zimbra.redolog||Redo log operations|
|zimbra.session||User session tracking|
|zimbra.smtp||SMTP operations (outgoing mail)|
|zimbra.store||Mail store disk operations|
|zimbra.sync||Sync client operations|
|zimbra.system||Start-up/shutdown and other system messages|
|zimbra.mailop||Changes to mailbox state|
|zimbra.purge||Mailbox purge operations|
Logging levels determine what types of events are logged. There are five logging levels in log4j:
The FATAL logging level will only log very severe error events. The DEBUG logging level will log detailed informational events useful for debugging purposes. Each additional logging level will log more events, including the events belonging to the previous logging levels. For example, enabling the WARN logging level will record log events belonging to the FATAL, ERROR, and WARN logging levels, but will not record events belonging to the INFO or DEBUG levels. By default, most predefined log4j categories in ZCS are set to the INFO logging level.
For more information on logging levels, see the ZCS Admin Guide > Monitoring Zimbra Servers > Log Files > Logging Levels.
Log output is directed to a log file by an appender. If an appender is not specified for a category, it inherits the appender of its parent category. By default, log output is directed to /opt/zimbra/log/mailbox.log. Additionally, Syslog captures FATAL and ERROR level events.
You can configure the log4j configuration file to direct log output to other predefined appenders, or even to user-defined appenders.
In the following example, the appender LOGFILE directs output from the log4j.logger.zimbra category to be written to /opt/zimbra/log/mailbox.log.
Changing the appender LOGFILE to a different predefined appender will cause the category to stop writing to LOGFILE and to begin writing to the new location.
You can also direct log output for a specific category to multiple appenders. In this example, the log4j.logger.zimbra category is writing logging events to the both LOGFILE and to SYSLOG appenders.
log4j.logger.zimbra=INFO, LOGFILE, SYSLOG
Adding another appender in addition to LOGFILE can be useful if you want to first quickly identify relevant logging events from a particular child category, and then review them with other logging events from other categories.