<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <meta http-equiv="X-UA-Compatible" content="IE=9"/> <meta name="generator" content="Doxygen 1.8.3.1"/> <title>log4c: Log4c : Logging for C Library</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="dynsections.js"></script> <link href="doxygen.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="top"><!-- do not remove this div, it is closed by doxygen! --> <div id="titlearea"> <table cellspacing="0" cellpadding="0"> <tbody> <tr style="height: 56px;"> <td style="padding-left: 0.5em;"> <div id="projectname">log4c  <span id="projectnumber">1.2.4</span> </div> </td> </tr> </tbody> </table> </div> <!-- end header part --> <!-- Generated by Doxygen 1.8.3.1 --> <div id="navrow1" class="tabs"> <ul class="tablist"> <li class="current"><a href="index.html"><span>Main Page</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> <li><a href="annotated.html"><span>Data Structures</span></a></li> <li><a href="files.html"><span>Files</span></a></li> </ul> </div> </div><!-- top --> <div class="header"> <div class="headertitle"> <div class="title">Log4c : Logging for C Library </div> </div> </div><!--header--> <div class="contents"> <div class="textblock"> <center> <a href="#summary">Summary</a> <a href="#requirements">Requirements</a> <a href="#installation">Installation</a> <a href="#config">Configuration</a> <a href="#custom">Customization</a> <a href="#thanks">Thanks</a> <a href="#copyright">Copyright</a> </center> <h1><a class="anchor" id="summary"></a> Summary</h1> <p>Log4c is a library of C for flexible logging to files, syslog and other destinations. It is modeled after the Log for Java library (<a href="http://jakarta.apache.org/log4j/">http://jakarta.apache.org/log4j/</a>), staying as close to their API as is reasonable. Here is a <a href="http://logging.apache.org/log4j/1.2/manual.html">short introduction</a> to Log4j which describes the API, and design rationale.</p> <p>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.</p> <p>Log4c is also available from SourceForge (<a href="http://www.sourceforge.net/projects/log4c/">http://www.sourceforge.net/projects/log4c/</a>). This is work in progress.</p> <h1><a class="anchor" id="requirements"></a> Requirements</h1> <h2><a class="anchor" id="platforms"></a> Platforms</h2> <p>log4c was successfully compiled and run on the following platforms:</p> <ul> <li>HP-UX release 11.00 </li> <li>Tru 64 release 4.0F and 5.1 </li> <li>Red Hat Linux Intel release 7.x, 8, 9 </li> <li>Red Hat Enterprise Linux 3, 4 </li> <li>Solaris Intel release 8, 9, 10 </li> <li>FreeBSD 6.1-RELEASE </li> <li>AIX 5.3 (with xlc compiler) </li> <li>Mac OS X </li> <li>Windows X </li> <li>...and other Linux distributions</li> </ul> <p>log4c should compile and run on the following platforms:</p> <ul> <li>The BSD family </li> <li>MS Windows</li> </ul> <h2><a class="anchor" id="software"></a> Software</h2> <p>The following software is needed to generate log4c:</p> <ul> <li><a href="http://gcc.gnu.org">GCC</a> 3.0.1+, to generate log4c, but hopefully not to use it. </li> <li><a href="http://www.stack.nl/~dimitri/doxygen/index.html">doxygen</a> 1.2.13+, a documentation system for C/C++ needed to generate the documentation. </li> <li><a href="http://www.graphviz.org/">graphviz</a>, the AT&T Graph Visualization Tools also needed to generate the documentation.</li> </ul> <p>For the moment, log4c uses specific GCC extensions, like <code><b>attribute</b></code>, so you will need GCC to compile it. This will probably change one day.</p> <h1><a class="anchor" id="installation"></a> Installation</h1> <h2><a class="anchor" id="installation_tarballs"></a> Building from source tarballs</h2> <p>on SourceForge: </p> <ul> <li><a href="http://prdownloads.sourceforge.net/log4c/log4c-1.2.4.tar.gz">log4c-1.2.4.tar.gz</a></li> </ul> <p>The log4c package uses the GNU autotools compilation and installation framework. The following commands should build log4c on the supported platforms:</p> <div class="fragment"><div class="line">$ gzip -dc log4c-1.2.4.tar.gz | tar tvf -</div> <div class="line">$ cd log4c-1.2.4/</div> <div class="line">$ ./configure --prefix=/path/of/installation</div> <div class="line">$ make</div> <div class="line">$ make install</div> </div><!-- fragment --><p>Checkout the <code>INSTALL</code> file for installation and the generated doxygen documentation for more information.</p> <h1><a class="anchor" id="config"></a> Configuration</h1> <h2><a class="anchor" id="conf_files"></a> Configuration files</h2> <p>log4c searches the following files to load its configuration:</p> <ul> <li><code>${LOG4C_RCPATH}/log4crc</code> </li> <li><code>${HOME}/</code>.log4crc </li> <li><code></code>./log4crc</li> </ul> <p>The environment variable <code>LOG4C_RCPATH</code> holds the prefix used for installation.</p> <h2><a class="anchor" id="conf_syntax"></a> Configuration syntax</h2> <p>The <code>log4crc</code> configuration file uses an XML syntax. The root element is <code></code> <log4c> and it can be used to control the configuration file version interface with the attribute <code>"version"</code>. The following 4 elements are supported: <code></code> <config>, <code></code> <category>, <code></code> <appender> and <code></code> <layout>.</p> <ul> <li>The <code></code> <config> element controls the global log4c configuration. It has 3 sub elements. The <code></code> <nocleanup> flag inhibits the log4c destructors routines. The <code></code> <bufsize> element sets the buffer size used to format <a class="el" href="structlog4c__logging__event__t.html" title="logging event object">log4c_logging_event_t</a> objects. If is set to 0, the allocation is dynamic (the <code></code> <debug> element is currently unused).</li> </ul> <ul> <li>The <code></code> <category> element has 3 possible attributes: the category <code>"name"</code>, the category <code>"priority"</code> and the category <code>"appender"</code>. Future versions will handle multiple appenders per category.</li> </ul> <ul> <li>The <code></code> <appender> element has 3 possible attributes: the appender <code>"name"</code>, the appender <code>"type"</code>, and the appender <code>"layout"</code>.</li> </ul> <ul> <li>The <code></code> <layout> element has 2 possible attributes: the layout <code>"name"</code> and the layout <code>"type"</code>.</li> </ul> <p>Here's the <code>log4crc</code> configuration file example:</p> <div class="fragment"><div class="line"><?xml version=<span class="stringliteral">"1.0"</span> encoding=<span class="stringliteral">"ISO-8859-1"</span>?></div> <div class="line"><!DOCTYPE log4c SYSTEM <span class="stringliteral">""</span>></div> <div class="line"></div> <div class="line"><log4c></div> <div class="line"></div> <div class="line"> <config></div> <div class="line"> <bufsize>0</bufsize></div> <div class="line"> <debug level=<span class="stringliteral">"0"</span>/></div> <div class="line"> <nocleanup>0</nocleanup></div> <div class="line"> </config></div> <div class="line"></div> <div class="line"> <!-- root category ========================================= --></div> <div class="line"> <category name=<span class="stringliteral">"root"</span> priority=<span class="stringliteral">"notice"</span>/></div> <div class="line"></div> <div class="line"> <!-- <span class="keywordflow">default</span> appenders ===================================== --></div> <div class="line"> <appender name=<span class="stringliteral">"stdout"</span> type=<span class="stringliteral">"stream"</span> layout=<span class="stringliteral">"basic"</span>/></div> <div class="line"> <appender name=<span class="stringliteral">"stderr"</span> type=<span class="stringliteral">"stream"</span> layout=<span class="stringliteral">"dated"</span>/></div> <div class="line"> <appender name=<span class="stringliteral">"syslog"</span> type=<span class="stringliteral">"syslog"</span> layout=<span class="stringliteral">"basic"</span>/></div> <div class="line"></div> <div class="line"> <!-- <span class="keywordflow">default</span> layouts ======================================= --></div> <div class="line"> <layout name=<span class="stringliteral">"basic"</span> type=<span class="stringliteral">"basic"</span>/></div> <div class="line"> <layout name=<span class="stringliteral">"dated"</span> type=<span class="stringliteral">"dated"</span>/></div> <div class="line"></log4c></div> </div><!-- fragment --><p>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.</p> <h2><a class="anchor" id="env"></a> Environment variables</h2> <ul> <li><code>LOG4C_RCPATH</code> holds the path to the main <code>log4crc</code> configuration file </li> <li><code>LOG4C_PRIORITY</code> holds the <code>"root"</code> category priority </li> <li><code>LOG4C_APPENDER</code> holds the <code>"root"</code> category appender</li> </ul> <h1><a class="anchor" id="custom"></a> Customization</h1> <p>This section will, one day, briefly describe how to define custom appenders and custom layouts. Be patient or checkout the source.</p> <h1><a class="anchor" id="thanks"></a> Thanks</h1> <p>Mark Mendel for his work on a previous version of log4c.</p> <p>This project would not have existed without Ceki Gulcu, the creator and maintainer of <a href="http://jakarta.apache.org/log4j">Log4j</a>, nor without Bastiaan Bakker, who initiated me with <a href="http://log4cpp.sourceforge.net/">Log4Cpp</a>.</p> <p>Many thanks to</p> <ul> <li>Joel Schaubert for many contributions </li> <li>Robert Byrne for Windows port and also many contributions </li> <li>Olger Warnier for the Mac OS X port </li> <li>Jeff Smith for writing a primer on <a href="http://jefficus.usask.ca/article.php?story=20040613140849924">how to use Log4c effectively</a></li> </ul> <h1><a class="anchor" id="copyright"></a> Copyright</h1> <p>All software in this package is Copyright (C) 2003-2004 Meiosys <a href="http://www.meiosys.com">http://www.meiosys.com</a> and Cedric Le Goater and is distributed under the <a href="http://www.gnu.org/licenses/lgpl.html">LGPL</a> License. See the <code>COPYING</code> file for full legal details. </p> </div></div><!-- contents --> <!-- start footer part --> <hr class="footer"/><address class="footer"><small> Generated by  <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/> </a> 1.8.3.1 </small></address> </body> </html>