- Log4c
Log4C is a C-based logging library. Its goal is to provide the C
Software developer with a configurable and efficient library for logging messages. It may be linked with end user applications or other libraries that will eventually be linked into applications. The library is released onSourceForge under theLGPL license. Postings to the Log4C mailing list suggest that the library has been used successfully in production with various C-compilers on various operating systems.Fundamental Log4C Concepts
Log4C follows the overall style of the native Java logging and
Log4j utilities. There are three fundamental types of object in Log4C: categories, appenders and layouts. You can think of these objects as corresponding to the what, where and how of the logging system: categories describe what sub-system the message relates to, appenders determine where the message goes and layouts determine how the message is formatted. There is always a "root" category which represents a conceptual root of the hierarchy of categories. The other concept fundamental to Log4C is the logging priority: each message has an associated priority. At a given point a given instance of Log4C has an associated configured priority--only messages with a higher priority than the current Log4C priority are sent to an appender for processing.Compiling Log4C itself
On the various
Unix operating systems the autoconf and automake files provided with Log4C are a natural way to compile the library. On Windows aMakefile is provided for use withMSVC . Developers may of course choose to use their own make system to compile the source, depending on their build engineering requirements.Development with Log4C
It is as simple as including log4c.h, and adding -llog4c to the linking options. For examples on using Log4C see the [http://log4c.cvs.sourceforge.net/log4c/log4c/doc/ doc directory] , [http://log4c.cvs.sourceforge.net/log4c/log4c/examples/ the examples] , and [http://log4c.cvs.sourceforge.net/log4c/log4c/tests/log4c/ the test programs] in the Log4c code repository, or [http://jefficus.usask.ca/article.php?story=20040613140849924 this short and effective article]
Configuration of Log4C at run time
An instance of the library may be configured via three methods
* Environment variables
* Programmatically
* A configuration fileThe environment variables typically provide a quick way to configure some parameters of Log4C, which are set in the environment of the application before it is started. Only a small subset of parameters may be set this way. Currently, the appender and priority for the root category can be set via the environment variables.
Programmatically, an application can configure all the parameters of Log4c. This is useful in the case where an application has its own configuration file and wishes to take logging parameters from that file rather than from a Log4C file.
Log4C is configurable via an
XML configuration file. This is useful for applications happy to hand over logging configuration entirely to Log4C. This is particularly useful on systems where many applications are using Log4c and can thus share the same logging configuration file: this allows the logging behaviour of all those applications to be controlled in a consistent way from one point of configuration.External links
* [http://log4c.sf.net Official Log4C Homepage]
* [http://sourceforge.net/docman/?group_id=38627 Log4C Documentation repository (developers guide etc.)]
* [http://sourceforge.net/mailarchive/forum.php?forum_name=log4c-devel Log4c developer mailing list - The mail archive shows this list to be 'quiet but very responsive']ee also
*
Log4j
* [http://pantheios.org/ Pantheios] - A C/C++ logging API library
Wikimedia Foundation. 2010.