Define in every file of your application, which wants to log something, a logging-category with log_define. This is a macro with one argument. This is defined in cxxtools/log.h.
To log something you use simple macros log_fatal, log_error, log_warn, log_info and log_debug, which gives you a std::ostream, where you can write your messages to. These are defined in cxxtools/log.h.
Link the cxxtools library to your application.
#include <cxxtools/loginit.h> #include <cxxtools/log.h> log_define("myapp") int main() { int ret = 0; log_init(); log_debug("this is a debug-message"); log_info("I will return " << ret); return ret; }
Makefile for it
CC=g++ LDFLAGS=-lcxxtools myapp: myapp.o
If you run make, a application named "myapp" is built. When run, it does nothing. To see the log messages, you need to enable logging with a property-file. The name of the property-file is either found in the environmentvariable LOGPROPERTIES or by default "log.properties" is used (at least with the default logging library).
Create now a file "log.properties":
rootlogger=INFO logger.myapp=DEBUG
If you run the application now, the log messages are printed to stdout. You can create a more detailed configuration file including comments using "cxxtools-config --properties myapp >log.properties
There is a more sophisticated exampleprogram at demo/log.cpp in the source-distribution. There you can find also some example-propertyfiles for the different libraies.