|
DataNucleus provides flexibility with logging. You can choose whether
to use the popular Log4J
or JDK1.4 logging for example. Moreover, DataNucleus allows you to log messages to various
categories, allowing users to filter the logged messages by these categories.
The
NucleusLogger
class provides the central registry of logging categories used by
DataNucleus. It provides an accessor for retrieving a particular logging category -- used as
follows
NucleusLogger.METADATA.info("my log message");
There are the various categories defined in the DataNucleusLogger class.
Only add new ones after discussion with other developers.
NucleusLogger will decide if Log4J, or JDK14 logging or other should be used - you don't
need to do anything in your code.
NucleusLogger allows you to log messages at various severity levels. These are
DEBUG
,
INFO
,
WARN
,
ERROR
,
FATAL
. Each message is logged at a particular level to a
category
(as described above).
To log a message is very simple. See below for a few examples
NucleusLogger.DATASTORE_SCHEMA.info("my log message");
NucleusLogger.DATASTORE_SCHEMA.error("my log message");
if (NucleusLogger.DATASTORE_SCHEMA.isDebugEnabled())
{
NucleusLogger.DATASTORE_SCHEMA.debug("my log message at debug level");
}
Please refer to
Log4J Manual
for details of what you can do with a Log4J Logger To see how you can use the logging from
a users perspective, refer to the User Logging Guide for
DataNucleus AccessPlatform.
DataNucleus provides an interface for allowing other types of logging if you so wish.
|
|