2

I have searched the web and log4cplus documentation for the question on how to use the log4cplus library in a pure C code and haven't found a clear answer. Is it possible?

DavidS
  • 2,160
  • 1
  • 19
  • 22
  • 1
    The only way is to make a C++ library which exports the functionality of log4cplus as functions callable by C. – Some programmer dude Nov 03 '15 at 12:52
  • I tried doing something like that but I was stuck when trying to pass a variable number of arguments to the log function. It seems [impossible](http://c-faq.com/varargs/handoff.html). Another [link](http://stackoverflow.com/questions/150543/forward-an-invocation-of-a-variadic-function-in-c). – DavidS Nov 03 '15 at 13:00

1 Answers1

5

log4cplus has limited C API since log4cplus 1.1.0-RC1. Branches 1.1.x and 1.2.x have the same API. Master, which will eventually become 2.0.x, has slightly modified and extended C API. In either case, they support printf-style formatted output. See clogger.h on 1.1.x branch or look at the same file on master, depending on which version of the library you are using.

The intention of this API is to provide logging support for applications with mixed C and C++ code. Its intention is not to provide 1:1 translation to C for the whole log4cplus.

wilx
  • 17,697
  • 6
  • 59
  • 114