Log4cpp is library of C++ classes for flexible logging to files, syslog, IDSA and other destinations. It is modeled
after the Log4j Java library, staying as close to their API as is reasonable.
Choose the latest stable version or a recent release candidate.
Get the latest version of the source code:
git clone https://github.com/log4cpp/log4cpp.git
./autogen.sh # optional
./configure
make
make check
make install
cmake -S . -B build_release -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$HOME/.local -DLOG4CPP_BUILD_EXAMPLES=ON
cmake --build build_release
cd build_release/tests; ctest
cd ../..; cmake --install build_release
Additional build methods are listed on the project website (http://log4cpp.sf.net/).
CMake usage examples are provided for two scenarios:
Building examples is enabled via the LOG4CPP_BUILD_EXAMPLES configuration option (-DLOG4CPP_BUILD_EXAMPLES=ON).
Both shared and static library variants are demonstrated.
The CMake usage examples can be built either:
log4cpp build (when LOG4CPP_BUILD_EXAMPLES is enabled), orlog4cpp from their own directories. To build an example as ash
cd examples/cmake_usages/log4cpp_as_subproject
cmake -S . -B build
cmake --build buildsh
cd examples/cmake_usages/log4cpp_as_package
cmake -S . -B build -DCMAKE_PREFIX_PATH=$HOME/.local # possible after log4cpp was installed with CMake
cmake --build build