You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avalon.apache.org by Neeme Praks <ne...@apache.org> on 2003/04/22 23:26:34 UTC

logging question

This time a bit tricky question about logging...

I would like to clarify, if I understand correctly the way logging is 
(supposed to be) implemented in Avalon in general and in Fortress in 
particular.
The usual setup is (AFAIU) that each component instance gets its own 
private logger and logs away, correct?
For example:
We have the following component instances, all of which are thread-safe 
and peers to each other: ComponentA, ComponentB, ComponentC.

ComponentA logs to component.a logger that is writing output to a.log
ComponentB logs to component.b logger that is writing output to b.log
ComponentC logs to component.c logger that is writing output to c.log

Suppose now that there is the following interaction between these 
components:
ComponentA looks up ComponentB and invokes some method on it.
In turn, ComponentB looks up ComponentC and invokes some method on that 
as well.

In the above setup, this could have resulted in the following log 
statements:
a.log:
0 ms ComponentA: invoking method on ComponentB

b.log:
1 ms ComponentB: method invoked
2 ms ComponentB: invoking method on ComponentC

c.log:
3 ms ComponentC: method invoked
4 ms ComponentC: returning from method

b.log:
5 ms ComponentB: returning from method

a.log:
6 ms ComponentA: returning from method

*Now the question*: would it be ok if all of the components would log to 
the same logger that would be passed on, together with the execution flow?
This would mean that before each method invocation, the component 
manager would have to call the enableLogging() method, to override the 
logger instance and after the method is done, it would have to set it 
back to the original logger... any better idea for implementing this?
Doesn't this mean that the lifecycle would be somewhat out of order, if 
enableLogging() is called more than once?

Example:
In addition to the above components, we would have two more components:
ServiceComponent1 that would be logging into service1.log
ServiceComponent2 that would be logging into service2.log

Both of these components would be using the same components (A, B and 
C), but with different glue code.
Now, what I need is the following output in logs:
service1.log
0 ms Service1: ComponentA: invoking method on ComponentB
1 ms Service1: ComponentB: method invoked
2 ms Service1: ComponentB: invoking method on ComponentC
3 ms Service1: ComponentC: method invoked
4 ms Service1: ComponentC: returning from method
5 ms Service1: ComponentB: returning from method
6 ms Service1: ComponentA: returning from method

service2.log
3 ms Service2: ComponentA: invoking method on ComponentB
4 ms Service2: ComponentB: method invoked
5 ms Service2: ComponentB: invoking method on ComponentC
6 ms Service2: ComponentC: method invoked
7 ms Service2: ComponentC: returning from method
8 ms Service2: ComponentB: returning from method
9 ms Service2: ComponentA: returning from method

Notice, that for some time, both ServiceComponent1 and ServiceComponent2 
are accessing the same method on the same component concurrently.

This would mean that the component would not be thread safe anymore, 
rather it would have to be poolable, right?

Or, would it be possible to make them semi-poolable: thread safe in 
relation to the accessing component?
Meaning that there can be two instances of ServiceComponent1 accessing 
the same instance of ComponentA, but if ServiceComponent2 would need to 
access ComponentA while ServiceComponent1 is already accessing it, 
ServiceComponent2 get a different instance of ComponentA...?
Or just good old poolable is good enough?

Rgds,
Neeme


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org