Log4c is a library of C for flexible logging to files, syslog and other destinations. It is modeled after the Log for Java library (http://jakarta.apache.org/log4j/), staying as close to their API as is reasonable. Here is a short introduction to Log4j which describes the API, and design rationale.
Mark Mendel started a parallel log4c projet with a different philosophy. The design is macro oriented, so much lighter and faster which perfect for kernel development.
Log4c is also available from SourceForge (http://www.sourceforge.net/projects/log4c/). This is work in progress.
log4c was successfully compiled and run on the following platforms:
log4c should compile and run on the following platforms:
The following software is needed to generate log4c:
For the moment, log4c uses specific GCC extensions, like
attribute, so you will need GCC to compile it. This will probably change one day.
The log4c package uses the GNU autotools compilation and installation framework. The following commands should build log4c on the supported platforms:
INSTALL file for installation and the generated doxygen documentation for more information.
log4c searches the following files to load its configuration:
The environment variable
LOG4C_RCPATH holds the prefix used for installation.
log4crc configuration file uses an XML syntax. The root element is
<log4c> and it can be used to control the configuration file version interface with the attribute
"version". The following 4 elements are supported:
<config> element controls the global log4c configuration. It has 3 sub elements. The
<nocleanup> flag inhibits the log4c destructors routines. The
<bufsize> element sets the buffer size used to format log4c_logging_event_t objects. If is set to 0, the allocation is dynamic (the
<debug> element is currently unused).
<category> element has 3 possible attributes: the category
"name", the category
"priority"and the category
"appender". Future versions will handle multiple appenders per category.
<appender> element has 3 possible attributes: the appender
"name", the appender
"type", and the appender
<layout> element has 2 possible attributes: the layout
"name"and the layout
log4crc configuration file example:
This initial version of the log4c configuration file syntax is quite different from log4j. XML seemed the best choice to keep the log4j configuration power in a C API.
LOG4C_RCPATHholds the path to the main
This section will, one day, briefly describe how to define custom appenders and custom layouts. Be patient or checkout the source.
Mark Mendel for his work on a previous version of log4c.
Many thanks to