The generation of log messages with Jadex agents is quite easy.
First you need a reference to the agent's
Logger
object that
can be acquired from an agent's plan helper method. On this object you can
call logging methods with an associated log level.
// get the agent's logger Logger logger= this.getLogger(); // Log simple INFO message logger.log(Level.INFO, "doing stuff");
For customizing purpose you can define logging properties in the agent description file (ADF). You can set the log level for the agent's logger object and specify if it should inherit the logging properties of the root logger.
<properties> <!-- Request all Details --> <property name = "logging.level">Level.ALL</property> <!-- use Handlers of parent (root) logger --> <property name = "logging.useParentHandlers">true</property> </properties>
For JADE agents there are neither helper methods to get the agent's logger object nor customizing possibilities using property files. But anyways, it is quite simple to use the logging functionality from JADE agents. The following example explains how to use logging methods in JADE.
// get logger with agent's name String name = getName(); logger = Logger.getLogger(name); // Request all Details logger.setLevel(Level.ALL); // use Handlers of parent (root) logger logger.setUseParentHandlers(true); // Log simple INFO message logger.log(Level.INFO, "doing stuff");
For examples of agents with logging functionality see code provided in the
src/examples/logging directory
.