You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4cxx-user@logging.apache.org by Thierry Lam <la...@pcigeomatics.com> on 2005/04/21 17:11:21 UTC
Differentiating calls to the same function
Consider the following example:
Calling function stuff()
Calling function doThing()
Calling function stuff()
In my log file, is there some feature which allows me to do the
following:
(date-time) 1st call to stuff()
(date-time) 1st call to doThing()
(date-time) 2nd call to stuff()
Thanks
Thierry
Re: Differentiating calls to the same function
Posted by Curt Arnold <ca...@apache.org>.
There are several technical reasons why it would be difficult and/or
expensive for log4j and log4cxx to provide a method invocation count
(the fairly substantial cost of obtaining location info in log4j is
one). It is a lot easier for the caller to maintain that count which
could either be formatted into the message or placed in a NDC or MDC.
Something like:
void stuff() {
static int callCount = 0;
callCount++;
LOG4CXX_DEBUG(std::string("Call to stuff() #") + itoa(callCount));
}
On Apr 21, 2005, at 10:11 AM, Thierry Lam wrote:
> Consider the following example:
>
> Calling function stuff()
> Calling function doThing()
> Calling function stuff()
>
> In my log file, is there some feature which allows me to do the
> following:
>
> (date-time) 1st call to stuff()
> (date-time) 1st call to doThing()
> (date-time) 2nd call to stuff()
>
>
> Thanks
> Thierry
>