tags:

views:

7143

answers:

14

I'm looking for logging framework for C++ project. My best shoot was log4cxx, but it seems that it's abandoned project, with development stopped ~4 years ago, with only one update in last 4-5 years.

Anything better that log4cxx? (log4c & log4cpp are also totally out-of-date)...

+6  A: 

Have a look at the logging library which has been proposed for the Boost C++ libraries.

See: http://torjo.com/log2/doc/html/index.html

+10  A: 

The Boost Logging framework seem pretty good. I've used it myself on a "toy project" but I haven't really tried it in a large application.

It was however rejected for inclusion in the official Boost library, by the author himself. Thats not because its not a good library, it just didn't fit into the Boost library in its current form.

Thomas Watnedal
+1  A: 

I've used NLog in our native C++ projects. Its primarily a .NET logging framework but it does offer a COM interop out of the box (which admittedly doesn't offer full functionality but the source code is available so you can grab the source and roll your own COM interop exposing the functionality that you need).

jpoh
+16  A: 

Update : this library have been accepted in Boost and will be available in a coming release


Another logging library (by Andrey Semashev ) have been proposed to boost and is currently in work in progress.

From the mailing list :

The archive with the library source code, tests and docs is available in the Vault:

http://tinyurl.com/cm9lum

The online docs are also available on the SourceForge page:

http://boost-log.sourceforge.net

The latest code snapshot can be downloaded from CVS on the SourceForge project page:

http://sourceforge.net/projects/boost-log

The code should be compatible with Boost 1.38. Might also work with 1.37, but I didn't try.

Klaim
bua
Well,it's a work in progress I guess.
Klaim
+8  A: 

You can take a look at this article, it discribes a simple, typesafe, threadsafe, portable logging mechanism.

Serge
+1 I implemented a logging system based on this article and was really happy with it. It's intuitive, flexible, low overhead and easy to use.
markh44
+6  A: 

Here is a log library from google glog

yesraaj
+1  A: 

http://log4cpp.sourceforge.net/ though LGPLed

Ram
+8  A: 

Checkout Pantheios. Haven't tried this myself, but have the greatest respect for Matthew Wilson.

Cwan
Pantheios still does not support unicode from what I can tell. Just spent some time evaluating it only to discover I can't use it due to this issue.
Avalanchis
The 4th April 2010 release claims full widestring compatibility
dcw
+5  A: 

I don't think that log4ccxx is abandoned at all. I am actually using the last release of log4cxx in my current project and it works pretty well. Yo can check it here

fco.javier.sanz
that link just confirms my state: "only one update in last 4-5 years"
Jox
I think it has just reached a level of stability - there really isn't anything more to add.
Martin Beckett
I think log4cxx tries to follow the lo4java design. Log4java has a 1.3 branch abandoned and another branch 2.0 that is still experimental. Version 1.2 of log4java has been there for while so I guess that without new versions of log4java there won't be new log4cxx
fco.javier.sanz
+1  A: 

I don't see why few updates to log4cxx are a bad thing, necessarily. It's working great in my project.

John K
Of course it's not necessarily a bad thing. Thing is we want to use out-of-the box tested logging framework, and log4cxx doesn't even compile in VS2k8 easily.
Jox
Ditto here-- it'd be pretty suite if log4cxx build on many newer compilers without requiring goofy, smack-yourself-in-the-forehead patches.
Rhys Ulerich
As well it can segfault in multithreaded apps (http://issues.apache.org/jira/browse/LOGCXX-322). This problem has been on the books for a year, with no fix.
rbellamy
+5  A: 

Pantheios is great, but no unicode/wchar_t support. Ditto for google-glog. One advantage of google-glog is that if you use gflags for options parsing, it builds upon it so that debug flags are automatically available for your program. But no wchar_t support is bad.

log4cxx requires apache portable runtime.

log4cplus is kinda primitive.

Boog.Log by Andrey Semashev really looks good. I am going to try it out and see how it goes.

I am just hoping that I don't have to end up rolling my own..

lenkite
Any updates on how Boost.Log worked for you?
Avalanchis
April 2010 release claims full widestring compatibility.
dcw
+8  A: 

I'm looking also for the same thing. So far I evaluated:

  • log4cplus - nice API, easy build, but memory leaks. The author does not care about the memory leaks and they will not be fixed I guess (see here)
  • log4cpp - nice API, easy build, but memory leaks
  • log4cxx - requires a bunch of apache stuff to get build (really annoyng until you build it) and at the end it has memory leaks... It is also very big
  • glog - so far version 0.3.0 - too early. Looks promesing though, but maybe later. It still has memory leaks, but it is small
  • ezlogger - cool nice small logging library. The only one without memory leaks! Unfortunately there are no features like configuration files, rolling logs e.t.c. Just logging, but works. It consists of several HPP files, so you just include them in your project. No need to build the whole world in order to work (Apache should learn from that!). The code looks nice, it has superb documentation, so anybody can extend it with whatever features in no time

I still want to look at Boost and the Pantheios, but I think ezlogger will be the tool of choice for me. Did I miss some library here? I'd like to make a complete list if possible.

m_pGladiator
It should be pointed out that those memory "leaks" for log4cplus are leaks in name, but not practice.
Steve
I consider a memory leak everything that allocates memory and not release it. Calling the operator new in a constructor and having empty corresponding destructor is a memory leak. The fact that the object is instantiated only once (so it leaks once and it is not growing) does not fix the leak.
m_pGladiator
Just watch if you use ezlogger's FUNCTRACKER stuff, it is not multithread safe because of the static my_stack member in ezlogger_output_policy::get_stack. Other macros should be safe or at least they don't use that member. I just got rid of it, you will loose the DISPLAYSTACK functions but if you don't need it it should work.
n1ck
Thanks n1ck! I actually have to post an update. Later the Pantheios shown the best performance and it was easy to write a custom backend for using it
m_pGladiator
+2  A: 

This one is another option: http://clp.sourceforge.net/, works for me

+1  A: 

log4cplus - nice API, easy build, but memory leaks. The author does not care about the memory leaks and they will not be fixed I guess (see here)

What you consider leaks are not leaks. The memory gets destroyed and freed properly, as far as I know, at static variables destruction time. IMHO your leak detector is showing false positives here. If your leak detector has any sort for textual output, please share it, attach it to the bug report.

wilx