Log4Tango
Introduction
"Log4Tango" is a light and custom version of Log4cpp for Tango.
Log4cpp is library of C++ classes for flexible logging to miscelaneous destinations.
It is modeled after the Log4j Java library.
Download
log4tango is part of the TANGO distribution. There is no way to obtain log4tango individually.
Building Log4Tango
The pthread (i.e. POSIX thread) library is required to compile log4tango.
log4tango can be build using autoconf on platforms that support it. Simply do:
./configure
make
make check
make install
This will install log4tango under /usr/local. To install in another localation specify --prefix=<location> when running configure.
Options for ./configure
Besides the usual ./configure options like --prefix a few others are available:
- --enable-doxyen
- Enables generation of API documentation by Dimitri van Heeschs Doxygen tool
(http://www.doxygen.org/). Defaults to yes if doxygen can be found in the
search path.
- --enable-html-docs
- If doxygen is enabled, have it generate HTML formatted documentation.
- --enable-latex-docs
- If doxygen is enabled, have it generate LaTeX formatted documentation.
- --enable-dot
- Let Doxygen use the 'dot' tool of GraphViz (http://www.graphviz.org) todraw its graphs.
Build notes for specific platforms
- *nix (including Linux) - g++ compiler
- Log4cpp should build whitout modification on any decent *nix system with g++ and GNU make. The primary development platform is
RedHat Linux 7.3, which has g++ 2.96-rh, but the aim is to be compatible with from g++ 2.95 and up. When g++ 3.x has been widely
adopted we may drop support for older g++ versions.
- Solaris - Sun CC compiler
- Compilation with Suns CC compiler requires setting some enviroment variables.
Also static libraries appear not to work. In short do:
CC=CC CXX=CC LD="CC -KPIC" ./configure --disable-static
- Win32 - MSVC++ 6
- Use the workspace and project files in subdirectory msvc6.
You may need to adjust include/log4cpp/config-win32.h and the project files to your particular needs.
Releases
- 2.2.0 - based on log4cpp-0.3.4b (24 February 2003)
-
Documentation
API Documentation generated by Doxygen can be found
here.
FAQ
1. GENERAL
1.1. What is Log for C++?
Log for C++ is a library of C++ classes for flexible logging to misc. destinations. It is modeled after the Log for Java
library (http://jakarta.apache.org/log4j/).
1.2. How is Log for C++ related to Log4j? Is it a straight port?
Log for C++ strives to supply a similar interface for logging in C++ as Log4j provides in Java. However the implementation is not a
translation of the Java code. So in that sense it is not a 'port' of Log4j. Of course Log for C++ does owe many of its concepts to log4j.
1.3. What is the name of this project, 'Log for C++' or 'log4cpp'?
The 'official' long name of the project is 'Log for C++', but in practice, the short name, 'log4cpp' has proven more convinient.
1.4. Under which license is Log for C++ available?
As of version 0.2.1 Log for C++ is released under the GNU Lesser General Public License (LGPL).
Versions before that have been released under the GPL. See the license discussion on the forum at SourceForge
for the motivations behind switching from GPL to LGPL.
1.5. Our legal department doesn't like the LGPL, can you release Log for C++ under license XYZ?
No.
Long answer: Technically it may be possible if every contributor agrees, which due to their growing number has become increasingly
difficult. But even if that could be overcome it will not happen.
Of course the LGPL does grant you the opportunity to choose the GPL instead of the LGPL, but I bet XYZ != GPL.
2. COMPILATION AND INSTALLATION
3. USAGE
3.1. I've succesfully compiled log4cpp, now how do I use this stuff?
For some small examples using log4cpp, see the 'tests' subdirectory. Also see the documentation section for a pointer for API documentation
and more usage information.
3.2. Is log4cpp thread-safe?
4. PROBLEMS AND ERROR MESSAGES
4.1. I get 'Naming collision for 'ERROR' detected. Please read the FAQ for a workaround.'
This is caused by the rudeness of some platforms, which mutilate the namespace with some blunt #defines. To be more precise,
the Win32 API includes #defines of 'ERROR' and 'DEBUG'. Since the preprocessor is unaware of C++ naming scopes this results in
reserving the words ERROR and DEBUG litterally everywhere. In particular this conflicts with log4cpp::Prioritiy::ERROR and
log4cpp::Priority::DEBUG. These latter two names come from log4j, so they are not something we made up ourselves.
They Win32 authors should not have rudelessly claimed these generic names through the preprocessor. There are much better alternatives:
- If they use it as an integer constant, declare it using a language construct.
Either 'enum {ERROR=1};' or 'static const int ERROR=1;' would do fine.
- Use a less generic name like WIN32API_ERROR to make naming conflicts less likely
- In case they use it as a flag for conditional compilation, use '#define DEBUG DEBUG' and '#if defined(DEBUG)'.
In that case the preprocessor would simply replace all occurrences of 'DEBUG' in the source code with 'DEBUG', in effect leaving
everything intact.
Of course the proper solution would be if the offending party would use one of the above methods, but we could have to wait
some time for this to actually happen. As an alternative log4cpp can workaround these #defines. The workaround code is enabled by
doing #define LOG4CPP_FIX_ERROR_COLLISION 1 before #including any log4cpp header files and after #including all
platform headers. For Win32 platforms this #define has already been included in log4cpp/config-win32.h.
Once log4cpp has been updated to the log4j 1.2 API we can get rid of this problem by adopting the new names for log levels.
4.2. I am trying to compile/link the log4cpp package using the SunWorkshop compiler (CC) on a Solaris 7 machine.
The library builds, but the testmain code fails to link properly.
A proper solution for this problem has not been found yet (suggestions are welcome),
but James Emery reported success with the following workaround:
- Disable building of the static library
- Change the linker from /usr/ucb/ld to CC and enable 'place independent code' (pic).
In short, configure with:
export LD="CC -Kpic" && ./configure --disable-static
4.3. ./configure fails to detect 'snprintf()' on platform XYZ.
./configure does not just check for the presence of a snprintf() function but for C99 compliancy as well. In particular, snprintf()
should strictly honour the 'string size' parameter to avoid potential buffer overflow problems.
log4cpp falls back to an alternative snprintf() implementation if the OS does not provide a correct one.
Status
As of version 0.3.0 log4cpp has a separate 'stable' and 'development' branches.
Releases x.y.z where y is even are considered stable and those where y is odd are experimental
(which means that some or all features may be broken).
The latest stable release 0.2.7. New releases of 0.2.x are for bug fixes only, new features will go into 0.3.x and eventually 0.4.x.
People
Coding on Log4cpp was initiated by me (Bastiaan Bakker) late 2000. Since then other people have joined the project or contributed code:
Cedric Le Goater <cedric(at)legoater.com> | autoconf setup, various improvements |
Marc Welz <marc(at)jade.cs.uct.ac.za> | IdsaAppender |
Lynn Owen <opl(at)agoby.com> | MSVC++ support |
Steve Ostlind <s.ostlind(at)pentasafe.com> | MSVC++ support, various fixes |
Marcel Harkema <marcel(at)debian.org> | Debian packaging |
Uwe J�er <jaeger(at)varial.de> | Borland C++ Builder support |
Walter Stroebel <walter.stroebel(at)lifeline.nl> | RemoteSyslogAppender |
Glen Scott <glen_s(at)yahoo.com> | PatternLayout, SimpleConfigurator |
Tony Cheung <dragonman(at)asiayeah.com> | OpenVMS support |
Alex Tapaccos <ATapaccos(at)redfig.com> | DailyRollingFileAppender |
Brendan B. Boerner <bboerner(at)texas.net> | Multiple Appender support for Categories |
Paulo Pizarro <paulo.pizarro(at)digitro.com.br> | RollingFileAppender |
David Resnick <dresnick(at)mobilespear.com> | NTEventAppender, integration work |
Aaron Ingram <ai8(at)yahoo.com> | MSThreads support |
Alan Anderson <alan(at)rushmore.com> | Win32DebugAppender, PropertyConfigurator |
Emiliano Martin <emilianomc(at)terra.es> | PThreads support |
Project Pages
Related Projects
Log4cpp is but one of many ports/implementations of the Log4j API. Here's an incomplete list:
log4c | An implementation in C by Cedric Legoater |
log4cplus | An indepent C++ implementation by Tad Smith.
Worth checking out if you don't like Log4cpp for some reason. |