Does log4cplus gives an API to print in C-Style / printf format?
Reason: I would like to use log4cplus in C code (in addition to C++) and don't want to prepare the string before hand.
All the logging macros have an FMT
variant that does what you expect:
LOG4CPLUS_WARN_FMT(logger, "Hello %s %d", "World", 1);
Compare/contrast with the "default" variant, which uses C++ streams:
LOG4CPLUS_WARN(logger, "Hello " << "World " << 1);
There's also an _STR
variant which can be used to output an std::string
if you have it ready (without paying for the overhead of a C++ string stream).