Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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.

share|improve this question

closed as primarily opinion-based by FrustratedWithFormsDesigner, GlenH7, MichaelT, gnat, Thomas Owens Jul 31 '13 at 16:16

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise.If this question can be reworded to fit the rules in the help center, please edit the question.

    
I noticed this question was closed. This site is WAY TOO harsh and opinionated as to what is suitable. Where can you go to ask advice about this type of question? Certainly not here, which is why I posted on SO. (I've given up on this site, and find no good reason to post here.) Get a grip guys! –  Sam Goldberg Oct 25 '13 at 18:22
add comment

2 Answers

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.
share|improve this answer
    
I don't mind evaluating the libraries. But for logging, which is really a secondary utility, I was hoping that there would be a developer consensus which had coalesced around one particular framework. (In Google searches, I didn't see a lot of discussion around logging in C++, and least not as much as compared to Java). –  Sam Goldberg Jul 5 '13 at 13:19
    
Are you using any logging framework consistently? –  Sam Goldberg Jul 5 '13 at 13:59
    
@SamGoldberg I've used log4cpp casually and in-house loggers professionally. –  congusbongus Jul 5 '13 at 14:15
add comment

Boost.Log is a part of the official Boost distribution since 1.54.0.

Today applications grow rapidly, becoming complicated and difficult to test and debug...

This library aims to make logging significantly easier for the application developer. It provides a wide range of out-of-the-box tools along with public interfaces for extending the library. The main goals of the library are:

  • Simplicity. A small example code snippet should be enough to get the feel of the library and be ready to use its basic features.
  • Extensibility. A user should be able to extend functionality of the library for collecting and storing information into logs.
  • Performance. The library should have as little performance impact on the user's application as possible...
share|improve this answer
    
That's good to know! (I have been using boost 1.46, so it wasn't part of my installed version.) –  Sam Goldberg Jul 5 '13 at 13:15
    
Are you using any logging framework consistently? –  Sam Goldberg Jul 5 '13 at 14:25
    
@Sam Goldberg I used to use John Torjo's logging library, which was proposed to Boost, but now I'm moving to the new Boost.Log. –  Igor R. Jul 5 '13 at 15:57
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.