I am considering starting to use the Boost.Log logging library. Is anyone using Boost.Log? Please share your experiences in this regard.
The other libraries I am considering are Apache log4cxx (it seems tedious to install but my team mates want something simple to get started) and Pantheios (the same problem since it works with extra front and back end).
Boost. Log, part of collection of the Boost C++ Libraries, provides tools for adding logging to libraries and applications.
The lg will refer to the one and only instance of the logger throughout the application, even if the application consists of multiple modules. The get function itself is thread-safe, so there is no need in additional synchronization around it.
UPDATE: I've since this was written replaced Boost.Log with my own custom logging, mostly because I decided to get rid of all Boost dependencies in all my projects for various reasons. If you are fine with using Boost I guess Boost.Log is still a valid choice judging by Klaim's answer.
My experience with Boost.Log in year 2010 follows.
I've successfully integrated Boost.Log in my game engine and I can only talk good things about it. Sure, it's a little early to use, since version 2 will be the actual version that will become the official Boost.Log.
Beware that the version "1.0" available is not being maintained. To receive updates you must use the bleeding edge (trunk) version which might become unstable. Take this into account if you are going to use this version in any serious projects. If you are not afraid to use bleeding edge versions or future breakage, then go for it. It's really nice to use as it is in its current state.
I've long thought the hierarchical logging system in log4j/log4cxx was superior, but Boost.Log has got me thinking otherwise. Filtering and attributes is way more flexible.
The design of sinks separated by frontend/backend makes it really easy to add additional backends. No need to worry about synchronization issues or filtering which is handled by the frontend. The library also comes with lots of backends already, rotational files, console, syslog, Windows event register, etc.
I have written my own sink backends; one goes to the in-game console and one to a kind of notification system for more serious events. Was easier than I expected, had it up and running in just a few minutes.
Last but not least, the maintainer/developer is really helpful as well. You'll get plenty of help in the project forums. He's fixed two bugs (whereof one major) just this weekend that I reported :-)
UPDATE: I am using Boost.Log into a game engine system and I am very happy with it. It's fast, thread-safe and very very flexible when you need it.
Boost.Log should be provided with all Boost libraries in a coming release this year (2013).
Boost.Log is made to setup a log system over it. If you read the documentation, you'll see that it's so flexible that any logging system yon can think of can be build with it (like logging on a distant computer).
So, there are macro to ease use in simple projects but I think it's the kind of library that is useful mostly to people that really understand logging and want to build a specific architecture for their application.
About performance, I remember that there was problems at the submission that made it slow compared to other (less flexible) logging libraries but as it was a draft and the first release is not out yet I would not bother if you're not coding a time-critical application.
In the end, I think it's simply too "new" to be evaluated "now". There is no other logging library that is as flexible as this one and I'm not sure if a lot of people will feel the need to use it.
Update: a recent email exchange with the Boost.Log author result in some data that suggest tat Boost.Log is clearly an excellent alternative for fast logging.
I recently looked into implementing a logging system on a project I was starting.
I tried log4cxx as you mention it, it is indeed very tedious to install. It took me several hours to get it to compile under VS2012 (with other dependency libraries...), and then it just crashed when I used it in my project. Certainly some weird stuff going on with standard libraries mismatches, but couldn't figure it out.
So I switched to log4cpp which I got up and running in just a few minutes. I find it elegant and lightweight, just what I needed. It has the big advantage of having the same features as the well-known log4j & co. logging systems which might be a real plus for your teamwork (configuration through config file, etc.)
As far as performance is concerned, it takes one function call to check if the logger is active for the level of the message, then one function call to actually log the data.
With a few home-made macros (to add LINE & co. to messages), log4cpp has really proven useful in my project.
Unfortunately, I didn't try Boost.Log so can't speak about it, but I hope this feedback will still be useful for you if you choose not to go the Boost.Log way.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With