Documentation Center

Logging from within Custom Components

SDL recommends that developers use log4j (http://logging.apache.org/log4j/docs/) to log status information from custom components.

Doing this will allow logging messages from your custom components to be written to the same log file as other WorldServer messages.

In order to do this, your component should declare a log4j Category as a static member and then use this member whenever you want to write content to the log file.

For example:
/**
  *
  */
import org.apache.log4j.Category;
public class MyComponent extends …
{
   /**
   * Information for logging.
   */
   private static final Category log =
      Category.getInstance(MyComponent.class.getName());

   public void myMethod()
   {
      …
      log.debug( “My Logging Message” );
   }
}

You can then enable logging for your component exactly as you do today; you modify the general.properties file to include additional logging directives.