cancel
Showing results for 
Search instead for 
Did you mean: 
cancel

using LogWrapper in a mult-threaded Agent app

230
Views
0
Helpful
0
Comments
Advisor
This blog was generated from CDN blog

Created by: David Lender on 19-11-2008 09:37:29 PM
If you are writing a multi-threaded agent mode app, there should only be one LogWrapper class object for the entire application. 

Declare the LogWrapper object as Static. If using either  Java and C# (i.e. the .NET Cil) build a Class called Tracer. In the Tracer class declare the LogWrapper as static. Then in each of the Agent handling Objects (e.g. CTIObject for each agent), declare a Tracer object. This allows each Agent handling object to write log messages for the Agent it is handling, and then the LogManager, which is also a singleton object, handles writing to the file specified and handled by the singleton LogWrapper Object.


So in each CTIObject objects (i.e. Agent handling object) declare a Trace object

// Tracer is a helper class that wraps the CIL Logger and
// provides some helpful tracing methods
private Tracer m_tracer = new Tracer();

Then when you want to log an event or message for that particular CTIObject you call the trace method on the Tracer object. So if you're handling 500 agents, you have 500 CTIObjects, and each has it's own Tracer Object, so there are 500 Tracer objects. All of the tracers are pointing to the single LogWrapper object.
This widget could not be displayed.