When you install Instant Messaging, a template file (log4j.conf.template) for the log4j configuration file is installed into the im-svr-base/lib directory. When you run the configure utility after installation, the template is used to create the log4j configuration file (log4j.conf) in the im-cfg-base directory. This configuration file is used to determine where to store log files generated by log4j, the logging level to use for various components, the output syntax, and to determine what log files to generate.
This section describes using the log4j logger to generate log files for Instant Messaging in the following sections:
Instant Messaging Log4j Configuration File (log4j.conf) Location
To Specify the Location of the Log4j Configuration File (Log4j.conf)
To Enable or Disable Log4j Logging for an Instant Messaging Component
To Specify the Maximum Log4j Log File Size for Instant Messaging Components
The logging levels described in Instant Messaging Component Logging Levels are used by the log4j logger.
For more information about log4j, and instructions on configuring aspects of log files, such as size, number of backups, etc., see the Apache Logging Services website.
You can change the location of the log4j configuration file, log4j.conf, by modifying the iim.log4j.config parameter in iim.conf. If you do not specify a value for this parameter, the logger will look in im-cfg-base. If the logger does not find the log4j configuration file in that directory, it uses the logging parameters in iim.conf to generate non-log4j style logs.
See Instant Messaging Server Directory Structure for information on locating im-cfg-base.
The configure utility generates the log4j configuration file (log4j.conf) based on the content of the log4j configuration file template (log4j.conf.template). Example 13–1 shows the log4j template. In this template:
${logdir} corresponds to the directory you specified during configuration in which you want to store log files. See Instant Messaging Log File Location.
Each component's log configuration section starts with the following text:
log4j.logger. |
Where:
Generates xmppd.log which contains logging information for the server.
Generates wd.log which contains information for the watchdog
Generates xfer.log which contains only for XMPP traffic.
Generates logging information for the Calendar agent.
Generates jso.log which contains information for Jabber stream objects. See the Jabber Stream Objects website for more information.
Generates genredirect.log which contains information for the redirect database creation tool.
A#, for example A1, are appender IDs.
log4j.logger.xmppd=INFO, A1 # DEFAULT TO RollingFileAppender log4j.appender.A1=org.apache.log4j.RollingFileAppender log4j.appender.A1.file=${logdir}/xmppd.log log4j.appender.A1.append=true log4j.appender.A1.maxBackupIndex=7 log4j.appender.A1.maxFileSize=5mb # More example appenders.. # Straight to console.. # log4j.appender.A1=org.apache.log4j.ConsoleAppender # log4j.appender.A1.ImmediateFlush=true # Rollover at midnight.. # log4j.appender.A1=org.apache.log4j.DailyRollingFileAppender # log4j.appender.A1.DatePattern='.'yyyy-MM-dd # log4j.appender.A1.file=${logdir}/xmppd.log # log4j.appender.A1.ImmediateFlush=true # log4j.appender.A1.append=true # Send to SMTP.. # log4j.appender.A1=org.apache.log4j.SMTPAppender # PATTERN LAYOUT AND OPTIONS # DEFAULT TO PatternLayout log4j.appender.A1.layout=org.apache.log4j.PatternLayout # For full dates.. log4j.appender.A1.layout.ConversionPattern=[%d{DATE}] %-5p %c [%t] %m%n # IM traditional output format.. #log4j.appender.A1.layout.ConversionPattern=%d{HH:mm:ss,SSS} %-5p %c [%t] %m%n # More example layouts # XMLLayout for chainsaw consumption # log4j.appender.A1.layout=org.apache.log4j.xml.XMLLayout # TTCCLayout for NDC information # log4j.appender.A1.layout=org.apache.log4j.xml.TTCCLayout # log4j.appender.A1.layout.DateFormat=ISO8601 # log4j.appender.A1.layout.TimeZoneID=GMT-8:00 # log4j.appender.A1.layout.CategoryPrefixing=false # log4j.appender.A1.layout.ThreadPrinting=false # log4j.appender.A1.layout.ContextPrinting=false # Now we list logger/appender/layout for the other default loggers, but # only the defaults.. log4j.logger.iim_wd=ERROR, A2 log4j.appender.A2=org.apache.log4j.RollingFileAppender log4j.appender.A2.file=${logdir}/iim_wd.log log4j.appender.A2.append=true log4j.appender.A2.maxBackupIndex=7 log4j.appender.A2.maxFileSize=5mb log4j.appender.A2.layout=org.apache.log4j.PatternLayout log4j.appender.A2.layout.ConversionPattern=[%d{DATE}] %-5p %c [%t] %m%n # For separate xmpp traffic log, disabled by default. log4j.logger.xmppd.xfer=DEBUG, A3 log4j.appender.A3=org.apache.log4j.varia.NullAppender # Select next block instead of previous line to enable separate transfer log # log4j.appender.A3=org.apache.log4j.RollingFileAppender # log4j.appender.A3.file=${logdir}/xfer.log # log4j.appender.A3.append=true # log4j.appender.A3.maxBackupIndex=7 # log4j.appender.A3.maxFileSize=5mb # log4j.appender.A3.layout=org.apache.log4j.PatternLayout # # Note, simpler default output than above 3 loggers: # log4j.appender.A3.layout.ConversionPattern=[%d{DATE}] %-5p %c [%t] %m%n log4j.logger.agent-calendar=ERROR, A4 log4j.appender.A4=org.apache.log4j.RollingFileAppender log4j.appender.A4.file=${logdir}/agent-calendar.log log4j.appender.A4.append=true log4j.appender.A4.maxBackupIndex=7 log4j.appender.A4.maxFileSize=5mb log4j.appender.A4.layout=org.apache.log4j.PatternLayout log4j.appender.A4.layout.ConversionPattern=[%d{DATE}] %-5p %c [%t] %m%n log4j.logger.net.outer_planes.jso.BasicStream=OFF, A5 log4j.appender.A5=org.apache.log4j.RollingFileAppender log4j.appender.A5.file=${logdir}/jso.log log4j.appender.A5.append=true log4j.appender.A5.maxBackupIndex=7 log4j.appender.A5.maxFileSize=5mb log4j.appender.A5.layout=org.apache.log4j.PatternLayout log4j.appender.A5.layout.ConversionPattern=[%d{DATE}] %-5p %c [%t] %m%n log4j.logger.genredirect=INFO, A6 log4j.appender.A6=org.apache.log4j.RollingFileAppender log4j.appender.A6.file=${logdir}/genredirect.log log4j.appender.A6.append=true log4j.appender.A6.maxBackupIndex=7 log4j.appender.A6.maxFileSize=5mb log4j.appender.A6.layout=org.apache.log4j.PatternLayout log4j.appender.A6.layout.ConversionPattern=[%d{DATE}] %-5p %c [%t] %m%n |
The log4j logger uses the same logging levels described for the iim.conf parameter-based logging mechanism in Instant Messaging Component Logging Levels.
Open iim.conf.
See iim.conf File Location for information on locating this file.
Set the iim.log4j.config parameter to the path in which you want the logger to look for log4j.conf.
For example, on Solaris:
iim.log4j.config=/etc/opt/SUNWiim/default/config/log4j.conf |
On Linux:
iim.log4j.config=/etc/opt/sun/im/default/config/log4j.conf |
Save and close iim.conf.
Refresh the server.
imadmin refresh |
By default, log4j logging is used for all components for which logging information is generated.
To disable log4j logging, set the logging level for the component to OFF in both log4j.conf and log4j.conf.template.
See To Set Log4j Log Levels for Instant Messaging for more information.
To enable log4j logging, set the logging level for the component to any logging level other than OFF in both log4j.conf and log4j.conf.template.
You can set log levels by modifying either the template or the log configuration file. However, if you only modify the configuration file, any changes you make will be overwritten the next time you run configure. To prevent this, you should make your changes to both the configuration file and the template.
Open log4j.conf.template.
By default, this file is stored in the following location:
im-svr-base/lib |
For each component, specify the logging level you want to use.
For example, to set the log level for the server:
log4j.logger.xmppd=log-level |
Where log-level is one of FATAL, ERROR, WARNING, INFO, or DEBUG.
See Table 13–1 for detailed information on each of these logging levels.
Save and close log4j.conf.template.
Repeat the procedure for the configuration file log4j.conf.
You can set log levels by modifying either the template or the log configuration file. However, if you only modify the configuration file, any changes you make will be overwritten the next time you run configure. To prevent this, you should make your changes to both the configuration file and the template.
Open log4j.conf.template.
By default, this file is stored in the following location:
im-svr-base/lib |
For each component, specify the maximum size for the component's log file.
For example, to set the size for the server log file:
log4j.appender.A1.maxFileSize=max-logfile-size |
Where A1 is the default appender ID for the server, max-logfile-size is in MB, for example 5MB.
Repeat the procedure for the configuration file log4j.conf.