You can write error messages to a
java.util.logging.Logger
object in order to have them
display in Forge's logs.
To log messages, use these recommendations:
Import the
JVM java.util.logging.Logger
into your Java manipulator code, and define your own logging object.Write log messages you want displayed in Forge’s logs to your
java.util.logging.Logger
object.This is generally done when implementing logging and debugging messages for Java manipulators and content adapters.
Note
Do not use
System.out
orSystem.err
for logging because messages written to either of these streams are not displayed in Forge’s logs.
For example, The
MBoxPlugin
content adapter logs informative messages
to a static
java.util.logging.Logger
class. In this case, the
Logger
is named
MBox Adapter
; logger names should normally be
based on the package name or class name of the logged component.
Messages written to this logger are displayed in the Forge log,
provided Forge is run with the appropriate verbosity (in this case
-vi
or lower; for details on Forge’s verbosity
levels, see the flag reference in the
Endeca Forge Guide). Adapter log messages appear in the
Forge logs with the name of the logger in parenthesis.
In the case of
MBoxPlugin
, messages appear as follows when Forge is
run with the
-vi
command line argument:
... INF: [Edf]: (AdapterRunner): Adapter class: MBoxPlugin INF: [Edf]: (MBoxPlugin): Creating <n> records. ... INF: [Edf]: (MBoxPlugin): Finished! ...
The
AdapterRunner
log message declares the content
adapter that was loaded.