We are porting our Java API library to C++. (Our target platforms are Linux and
ID: 654681 • Letter: W
Question
We are porting our Java API library to C++. (Our target platforms are Linux and Windows.) Since we have minimal C++ experience, the learning curve has been pretty steep, but overall we have been able to make a clean port so far.
In Java we use log4j, and are looking at to use log4cxx in the C++ version. It took us a few hours to get log4cxx to build on Windows (due both to our inexperience, and also build documentation seems out of date). We haven't yet tried to build on Linux.
To my uninformed eye, log4cxx seems messy and somewhat outdated. Is there any consensus on whether this is a good logging framework to go forward with? (Log4j also seems to have been superceded by SLF4J and Logback.)
I looked also at boost logging, but that does not appear to be part of the main distribution, so I wasn't sure if I was provided a more standard option with that or not.
One other piece of information to add into the evaluation - the first client we are providing this to is already using log4cxx.
Explanation / Answer
One thing you need to understand, coming from Java to C++, is that it does not have a single, monolithic, standard library. It's a key weakness of C++, and something that the language committee is very keen on addressing, but time - and plenty of it - will tell whether that can be improved.
This means that you need to become comfortable with finding and evaluating third-party libraries on your own. This doesn't mean that C++ doesn't have high-quality libraries though! A lot of third-party libraries are very good, and are used by many projects. It's just that without a central authority to put their seal of approval over it, you have to do the investigation yourself. Note that there have been many bugs in the standard libraries of Java, C# and so on, so not being a part of the "standard" library doesn't automatically mean it's untrustworthy.
A few points that may help you:
Boost is a very safe choice; it is used by a lot of people, and parts of it are so good that they eventually make it into the C++ language and standard libraries. Be aware however that its quality is not uniform; stick to the commonly used parts and away from the fringes and you'll be fine. This is not meant as a jab at Boost; it's a common symptom of any large library to have unstable fringes.
Any library that is used by many people, and is actively and well maintained, stands a good chance of being high quality. Speak to your peers to find out which libraries they recommend, or do your own investigation. I don't know if log4cxx falls into this category; ask those familiar with it.
Sometimes you need a library that does something very obscure, or for whatever reason there's no impetus for anyone to make a good library for it. Then you have to make some tough decisions, such as finding some flaky open-source library and getting it up to scratch, writing your own, or paying some vendor to do it.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.