Is there a reliable way to ensure that X number of log messages get
written out per second?  I ask because one of the problems that we
have with log4cxx is that the TimeBasedRollingTest randomly fails(on
OSX).  I've narrowed it down to the following function:

void logMsgAndSleep(Pool & pool,
size_t howOften,
std::string srcFunc,
size_t srcLine,
size_t startWith = 0,
float waitFactor = 0.5)
{

for (size_t i = startWith; i < startWith + howOften; ++i)
{
std::string message("Hello---");
message.append(pool.itoa(i));

LOG4CXX_DEBUG(logger, message);
apr_sleep(APR_USEC_PER_SEC * waitFactor);
}

}

The issue seems to be that due to various scheduling whims, we may not
always get the correct number of messages printed out per second, so
the test will fail.  Is there a better way to do this, perhaps
something in log4j?

-Robert Middleton

Reply via email to