|
![]() |
TestSuite API offers to tests developers a log system, to tace or debug their tests.
As in ProActive API we choose Jakarta Log4J like logger.
A static logger is create in Manager, all Groups and Tests who are added in the Manager have a reference to this logger.
By default all logs are written in a simple text file : $HOME/tests.log
With this file, it very easy to debug your test. You can also, with Log4J, specify a different place and different format for your logs. For more details see the next part.
To add logs in your Test code it is very easy : you can directly use the variable logger or the getter getLogger(). This is a org.apache.log4j.Logger
In your Test code just add logs like this :
if (logger.isDebugEnabled())
logger.debug("A debug message ...");
For more information about use logger see the log4J manual.
By default all logs with a level higher than INFO are written in $HOME/tests.log.
But you can configure the format and plac where you want to get logs.
The log4j environment is fully configurable programmatically. However, it is far more flexible to configure log4j using configuration files. Currently, configuration files can be written in XML or in Java properties (key=value) format.
You can also configure the logger by the configuration file.
Use default configuration of log4J. Add this code Manager constructor :
// Set up a simple configuration that logs on the console.
BasicConfigurator.configure();
An another example to write logs in a HTML file :
public YourManager() {
super("Function calls", "Alpha version");
HTMLLayout layout = new HTMLLayout();
WriterAppender appender = null;
try {
FileOutputStream output = new FileOutputStream(
"/net/home/adicosta/output2.html");
appender = new WriterAppender(layout, output);
} catch (Exception e) {
}
logger.addAppender(appender);
logger.setLevel(Level.DEBUG);
}
For more information about logger configuration see the log4J manual.