Log4c

From Wikipedia, the free encyclopedia

The correct title of this article is log4c. The initial letter is shown capitalized due to technical restrictions.

Log4C is a C-based logging library. Its goal is 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 on SourceForge under the LGPL 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.

Contents

[edit] 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.

[edit] 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 a Makefile is provided for use with MSVC. Developers may of course choose to use their own make system to compile the source, depending on their build engineering requirements.

[edit] Development with Log4C

Include log4c.h, add -llog4c to your link option and, like, get logging dude! For examples on using Log4C see the doc directory, the examples, and the test programs in the Log4c code repository, or this short and effective article

[edit] Configuration of Log4C at run time

An instance of the library may be configured via three methods

  • Environment variables
  • Programmatically
  • A configuration file

The 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.

[edit] External links

[edit] See also

  • Log4j
  • Pantheios - "The C++ Logging Sweetspot" - A C/C++ logging API library that combines 100% type-safety, atomicity, genericity, extensibility, portability and very high efficiency. And it upholds the Spirit of C: you only pay for what you use. It comes bundled with several stock transports, and is easily extensible to use large, feature-rich logging libraries, such as ACE, log4cpp, log4cxx, log4cplus.