You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by msew <ms...@ev1.net> on 2001/01/22 05:36:58 UTC
called and callee logging :-)
Is there any way in the current architecture to make a category that will
log everything called by a specific function across packages?
ie I have a method foo.bar.UberM() and it calls:
foo.baz.m1()
bar.foop.m2()
crazy.foo.bar.m3()
crazy.foo.bar.m5()
and each of those other methods call a LOT OF STUFF.
but I don't really know what those all call. I just want to
say: ANYTHING that UberM() calls I want to set that to print out debug
statements.
yes this will be REALLY REALLY REALLY slow as each call has to look on
the stack to see if was called by UberM() (though one could make some flag
in the log4j static structure. )
but can you do it in the current log4j? :-)
thanks
msew
Re: called and callee logging :-)
Posted by "Max R. Andersen" <ma...@cs.auc.dk>.
> >ie I have a method foo.bar.UberM() and it calls:
> >
> >
> >foo.baz.m1()
> >bar.foop.m2()
> >
> >crazy.foo.bar.m3()
> >crazy.foo.bar.m5()
> >
> >
> >and each of those other methods call a LOT OF STUFF.
> >
> >but I don't really know what those all call. I just want to
> >say: ANYTHING that UberM() calls I want to set that to print out debug
> >statements.
This is exactly what AspectJ was created for :)
To do cross-cutting programming...check out www.aspectj.org
By using aspectj you do not even have to insert the log statetments manually
in each method :)
Regards
Max
Re: called and callee logging :-)
Posted by Ceki Gulcu <cg...@urbanet.ch>.
At 20:36 21.01.2001 -0800, you wrote:
>Is there any way in the current architecture to make a category that will
>log everything called by a specific function across packages?
>
>
>ie I have a method foo.bar.UberM() and it calls:
>
>
>foo.baz.m1()
>bar.foop.m2()
>
>crazy.foo.bar.m3()
>crazy.foo.bar.m5()
>
>
>and each of those other methods call a LOT OF STUFF.
>
>but I don't really know what those all call. I just want to
>say: ANYTHING that UberM() calls I want to set that to print out debug
>statements.
>
>
>
>yes this will be REALLY REALLY REALLY slow as each call has to look on
>the stack to see if was called by UberM() (though one could make some
>flag in the log4j static structure. )
I think you might be lucky on this one. Here is a relatively easy solution:
1) At the start of foo.bar.UberM() set the NDC to some value that is easy
to recognize later.
2) Add filters to appenders where you want to isolate foo.bar.UberM()
tracing. These filters should accept logs that contain the NDC pattern that
was specified in (1) and reject all other logging events.
3) Clear the NDC when you leave foo.bar.UberM().
I predict that you can have this implemented and running in 30 minutes. See
the filters in org/apache/log4j/varia for filtering examples. Hope this
helps, Ceki
----
Ceki Gülcü (cgu@urbanet.ch)