Boost logo

Boost :

From: Simon J. Julier (sjulier_at_[hidden])
Date: 2004-03-19 07:12:19


I'm very interested in the question of logging libraries as well.

>There are a few log4J ones out there. I've been using Log4cplus from
>sourceforge and a been happy enough with it for its simple purpose.

I personally agree. I've tried various different logging strategies
including various types of macros and globally set log levels. However, I
typically find that those approaches don't provide a sufficiently
fine-grained approach when I debug code. (e.g., I might want some code to
be hyperverbose and other bits to remain quiet). I like the additivity,
hierarchical logger strategies of log4J et al. because they given a fairly
fine-grained control over what gets logged and how.

I've personally been using log4cpp (looks almost like log4cplus). It has
two solutions to the issue of the cost of logging a message:

1. You can query the logger to see if the message would be logged if it
were generated. Therefore, you can do things like:

if (logger.isDebugEnabled()) logger.getDebugStream() << message ;

(the stream support leaves a lot to be desired)

2. You can also log messages using printf-style commands:

logger.debug("%s", message);

These don't get evaluated unless the message is logged.

Cheers,

Simon


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk