📜 ⬆️ ⬇️

Log4cplus logging library

Recently, a couple of articles about logging libraries for C ++ flashed on Habré. The articles are good and intelligible, the author respects. But personally, I do not understand the following things:
Therefore, I decided to talk about a library such as log4cplus , which has:

I, as in previous articles, will describe the use of this library in Microsoft Visual Studio 2010 sp1.
  1. So, download the latest version of the library: log4cplus-1.0.4.tar.bz2
  2. Unzip.
  3. In Visual Studio, we tear off the log4cplus-1.0.4 \ msvc8 \ log4cplus.sln solution. It is in the process of converting under the tenth studio.
  4. We compile in the necessary configuration (I compiled in Release_Unicode).
  5. Create a test project - a console application.
  6. Add according to either log4cplusUS.lib.
  7. Add to Additional Include Directories the path to log4cplus-1.0.4 \ include
  8. We write the following code:
    #include "stdafx.h" #include <log4cplus/logger.h> #include <log4cplus/configurator.h> #include <iomanip> using namespace log4cplus; int main() { BasicConfigurator config; config.configure(); Logger logger = Logger::getInstance(_T("main")); LOG4CPLUS_WARN(logger, _T("Hello, World!")); return 0; } 
  9. We put log4cplusU.dll (it was compiled at the 4th step) next to the exe-file of the test project.
  10. We start. We see in the console the output of our logger.
  11. PROFIT!
Then you can start picking config files, writing your appenders and layouts, etc. Who cares - here is a slightly deeper article about these things. And here are a couple of examples .

')

Source: https://habr.com/ru/post/118165/


All Articles