Cisco Cisco Computer Telephony Integration Option 9.0 开发者指南

下载
页码 668
 
B-11
CTI OS Developer’s Guide for Cisco ICM/IPCC Enterprise & Hosted Editions Release 7.1(1)
 
Appendix B      CTI OS Logging
Logging and Tracing (.NET)
How to Log Trace Events Using the Logger Class
To log trace events from a custom application to a file, perform the following 
steps:
Step 1
Create a Logger object. For example:
m_log = new Logger();
Step 2
Write a method to handle log events. This method can trace the log events to a 
file, if desired. For example:
public virtual void ProcessLogEvent(Object eventSender, LogEventArgs 
Evt)
{
// Output the trace
String traceLine = Evt.Description;
// Check that tracing is enabled for this tracelevel
if ( m_logger.IsTraceMaskEnabled(traceLevel) )
{
WriteTraceLineToFile(traceLine);
}
Step 3
Create a log listener to handle trace events. In the following example, the 
AddLogListener method registers the LogEventHandler delegate as a listener for 
trace events. The LogManager will send trace events to the method that you pass 
to the LogEventHandler. 
In the following example, the LogManager will send trace events to the 
ProcessLogEvent method created in Step 2. 
m_log.AddLogListener(new LogManager.LogEventHandler(ProcessLogEvent));
Note
The LogManager only calls the method passed as a parameter to the 
LogEventHandler for a particular trace if the trace level for that trace is enabled. 
You can use the IsTraceMaskEnabled method in the Logger class to determine 
whether or not a trace level is enabled.