Message and trace logging


Portlets can write message and trace information to log files, which are maintained in the wp_root/log/ directory. The log files help the portal administrator investigate portlet errors and special conditions and help the portlet developer test and debug portlets. The Portlet API provides the PortletLog class, which has methods to write message and trace information to the logs.

See System event logging for a description of the log files.

If you access the portlet log multiple times in a method it is good idea to assign the log reference to a variable, for example:


  private PortletLog myLogRef = getPortletLog();

Since logging operations are expensive, PortletLog provides methods to determine if logging is enabled for a given level. Your portlets should write to the log of a given level only if the log is tracking messages of that level. For example:


  if( getPortletLog().isDebugEnabled() )
  {
    myLogRef.debug("Warning, Portlet Resources are low!");
  }

For more information about logging in WebSphere Portal, see System event logging.

See also