Documentation Center

Logging from within custom components

You should use Apache Log4j to log status information from custom components. By doing so, the logging messages from your custom components are written to the same log file as WorldServer messages.

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 for WorldServer – by including additional logging information in the general.properties file.