You can use the Forge log and JVM
Logger
class to help debug your Java manipulators.
Use the following features to assist you in debugging Java manipulators:
Import the
JVM java.util.logging.Logger
class, so that you can use itssevere
,warning,
info
,config
,fine
,finer
andfinest
methods in your Java manipulator code to print log messages to the Forge log file.Here is the relevant code from the sample that enables logging:
Note
Do not use
System.out
orSystem.err
for logging because messages written to either of these streams are not displayed in Forge logs.//import the logging API that comes with JVM. import java.util.logging.Logger; ... //Define the logger Logger log = Logger.getLogger(this.getClass().getName());
The
Logger
class has several methods which can be used to log messages of different severity levels. An example of one of these from the sample is the line://Print a message using the log to your console, letting you know that forge has entered the TextCleaner javamanipulator log.info("Inside the TextCleaner adapter");
View the Forge log to locate the command that was used to call a specific JVM running your Java manipulator.
In general, any messages that are printed using the
JVM Logger
class are automatically picked up by the Forge logging system and output into the Forge log file.The name of the log file is
Edf.Pipeline.RecordPipeline.JavaManipulator.
. It is located in the Forge working directory. In the log file name,<JM_NAME>
.logJM_NAME
is the name of your Java manipulator.Note
Once an error or warning occurs in the Java processing, it gets passed to the Forge processing console and is displayed and logged in the
Edf.Pipeline.RecordPipeline.JavaManipulator.
file.<JM_NAME>
.log
In addition to the Java manipulator logging, for cases in which logging does not catch all relevant information, you can insert additional components to your pipeline, or create an additional pipeline.
For example, you can insert an output record adapter in the pipeline, after the Java manipulator, to write the records to a file that you can examine.
Or, you can create an additional simple pipeline. This pipeline can write the records emitted by the Java manipulator that you are debugging into an XML file. The pipeline will contain two items: the Java manipulator that you are testing, and an XML output record manipulator that writes all records produced by the test Java manipulator to an XML output file.