Cisco Cisco Computer Telephony Integration Option 9.0 Developer's Guide

Page of 640
B-5
CTI OS Developer’s Guide for Cisco ICM/IPCC Enterprise & Hosted Editions Release 7.0(0)
 
Appendix B      CTI OS Logging
Logging and Tracing (.NET)
Using the Default Logging Mechanism
You can use the .NET CIL LogWrapper class to implement logging to the system 
console or to a file. The LogWrapper class registers itself as an event listener and 
creates a log file.
How to Log Trace Events Using the LogWrapper Class
To log trace events using the LogWrapper class:
Step 1
Create an instance of the LogWrapper class, passing the following arguments:
  •
logFileName - Name of file in which to write trace events 
  •
fileMaxSize - The maximum size of the log file
  •
numberArchivesFiles - Maximum number of log files that may exist in the log 
file directory before the logging mechanism starts overwriting old files
  •
numberDaysBeforeFileExpired - Maximum number of days before a log file 
is rolled over into a new log file regardless of the size of the file.
The following code snippet creates an instance of the LogWrapper class that 
writes trace events to MyLogFile.txt. When MyLogFile.txt reaches 2048 KB, a 
new log file is created. The Logger creates a maximum of 20 log files in the log 
file directory before overwriting existing files . After 10 days, the log file is rolled 
over into a new log file regardless of its size.
// Create a LogWrapper. This will create a file and start 
// listening for log events to write to the file.
String logFileName                 = "MyLogFile.txt";
int    fileMaxSize                 = 2048;
int    numberArchivesFiles         = 20;
int    numberDaysBeforeFileExpired = 10;
m_logWrapper = new LogWrapper(logFileName, fileMaxSize, 
numberArchivesFiles, numberDaysBeforeFileExpired);
 
Step 2
In your application, write trace events. The following example traces a message 
at the given trace level for the given method. Set the trace level to the desired trace 
mask. Trace masks are defined in the Logger class. See 
 for a list of 
available trace mask values.
protected internal static void MyTrace (
 
int traceLevel,
string methodName,