Db4o messaging system is a special tool, which makes db4o functionality more transparent to the user. It can be used:
In order to activate messaging before opening a database file use:
Java: Db4o.configure().messageLevel(level)
where level can be:
level = 0: no messages;
level > 0: normal messages;
level > 1: state messages (new object, object update, delete);
level > 2: activation messages (object activated, deactivated).
In order to set up a convenient output stream for the messages, call:
Java:
Db4o.configure().setOut(outStream)
By default the output is sent to System.out.
For more information on #setOut call see Customizing The Debug Message Output.
#messageLevel(level) also can be set after a database has been opened:
Java: ObjectContainer#ext().configure().messageLevel(level)
The same applies for #setOut().
Let's use the simplest example to see all types of debug messages:
01public static void setCars() 02
{ 03
// Set the debug message levet to the maximum 04
Db4o.configure().messageLevel(3); 05
06
// Do some db4o operations 07
new File(YAPFILENAME).delete(); 08
ObjectContainer db=Db4o.openFile(YAPFILENAME); 09
try { 10
Car car1 = new Car("BMW"); 11
db.set(car1); 12
Car car2 = new Car("Ferrari"); 13
db.set(car2); 14
db.deactivate(car1,2); 15
Query query = db.query(); 16
query.constrain(Car.class); 17
ObjectSet results = query.execute(); 18
listResult(results); 19
} finally { 20
db.close(); 21
} 22
Db4o.configure().messageLevel(0); 23
}
Output looks quite messy, but allows you to follow the whole process. For debugging purposes messaging system provides a timestamp and internal ID information for each object (first number in state and activate messages).