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:
configuration.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:
configuration.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:
01private static void setCars() 02
{ 03
// Set the debug message levet to the maximum 04
Configuration configuration = Db4o.newConfiguration(); 05
configuration.messageLevel(3); 06
07
// Do some db4o operations 08
new File(DB4O_FILE_NAME).delete(); 09
ObjectContainer container=Db4o.openFile(configuration, DB4O_FILE_NAME); 10
try { 11
Car car1 = new Car("BMW"); 12
container.set(car1); 13
Car car2 = new Car("Ferrari"); 14
container.set(car2); 15
container.deactivate(car1,2); 16
Query query = container.query(); 17
query.constrain(Car.class); 18
ObjectSet results = query.execute(); 19
listResult(results); 20
} finally { 21
container.close(); 22
} 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).