HOWTO: Use the Logging System

Preliminaries

This document explains how to use the logging system of Gravisto. Please note that you should not use System.out.println, System.err.println, or something similar to make some debug output of your code. Instead use the predefined logging system as described in the following.

Properties

The property file org/gravisto/editor/Logging.properties in the Graffiti_Editor package enables you to customize your log level, i.e., how much will be logged. Here you can also customize if you want to have debug info written to your console. If you don't then delete the lines

java.util.logging.ConsoleHandler.level= ALL
java.util.logging.ConsoleHandler.formatter= org.graffiti.util.logging.SimpleFormatter
      

from the file. The handler above defines that log outputs will be written to the file run.log which you can find on the top level of your Graffiti_Editor package after running Gravisto at least once.

Generate Log Output

To generate log output from your own code your first should import the Java Logger package and afterwards define a member variable logger as defined in the following code fragment:

import java.util.logging.Logger;

public class MyAlgorithm 
  extends AbstractAlgorithm
{
  private static final Logger logger = Logger.getLogger(MyAlgorithm.class.getName());

  ...

  public MyMethod()
  {

    ...

    logger.log(Level.INFO, "This is an info debug message.");

    ...

  }
}
      

As you see in MyMethod() you can write to the logger, e.g., with log where Level.INFO is a predefined Java log level.