- Preface
- Introduction
- CTI OS Client Interface Library Architecture
- CIL Coding Conventions
- Building Your Custom CTI Application
- CTI OS ActiveX Controls
- Event Interfaces and Events
- CtiOs Object
- Session Object
- Agent Object
- Call Object
- SkillGroup Object
- Helper Classes
- SilentMonitorManager Object
- CTI OS Keywords and Enumerated Types
- CTI OS Logging
CTI OS Logging
This appendix discusses a few issues related to CTI OS logging.
- CTI OS Client Logs (COM and C++)
- Set Trace Levels (COM and C++)
- Trace Configuration (COM and C++)
- Java CIL Logging Utilities
- Logging and tracing (Java)
- Logging and tracing (.NET)
CTI OS Client Logs (COM and C++)
If you install the tracing mechanism, the COM and C++ CILs automatically create a log file and trace to it. The trace log file name and location for client processes is found under the following Windows registry key:
HKEY_LOCAL_MACHINE\Software\Cisco Systems, Inc.\CTIOS TracingThe default filename is CtiosClientLog. Log files are created using the convention <TraceFileName>.<Windows user name>.mmdd.hhmmss.log. The files are created in the current directory of the executing program, such as the directory into which you install the Agent Desktop. You can provide a fully qualified path for the TraceFileName if you wish to store the files in a different location. For example, setting the following value stores the log files in the directory C:\Temp, using the naming convention CtiosClientLog.<Windows user name>.mmdd.hhmmss.log.
C:\Temp\CtiosClientLog
Client trace files are formatted in ASCII text that you can open them with a conventional text editor such as Notepad.
Install Tracing Mechanism (COM and C++)
Set Trace Levels (COM and C++)
You must set the trace level in the registry by creating a TraceMask registry value within the HKEY_LOCAL_MACHINE\Software\Cisco Systems, Inc.\CTIOS Tracing key and setting its value to 0x40000307.
[HKEY_CURRENT_USER\Software\Cisco Systems, Inc.\CTIOS Tracing]"TraceMask"=dword:40000307Trace levels for client processes, such as the Agent Desktop phone, are stored under the following registry key:
[HKEY_LOCAL_MACHINE\SOFTWARE\Cisco Systems, Inc.\CTIOS Tracing] "TraceFileName"="%HOMEPATH%\\CtiOsClientLog" "TraceMask"=dword:00000000 "MaxDaysBeforeExpire"=dword:00000007 "MaxFiles"=dword:00000005 "MaxFileSizeKb"=dword:00000800 "FlushIntervalSeconds"=dword:0000001e "TraceServer"="C:\\Program Files\\Cisco Systems\\CTIOS Client\\CTIOS Toolkit\\Win32 CIL\\Trace\\CTIOSTraceText.exe"
For CTIOS server versions 7.5(10), 8.0(3) and later the default trace level will not print the call variable in CTIOS sever logs. This has been done as an enhancement to reduce the log size in these two versions and above. To get the call variable in CTIOS logs you need to set the trace level to 0x400000.
Note | You can configure CTI OS Tracing globally for the entire machine (using the TraceMask setting on HKLM) and per user (using the TraceMask setting on HKCU). |
Warning | If the TraceMask is not set or if it is set incorrectly, the application's performance can be negatively affected. The preferred setting for normal operation is 0x40000307. |
Trace Configuration (COM and C++)
You can set C++ and COM client trace configuration parameters in the Windows registry at the following key. For more information about configuring tracing for the Java CIL, see Java CIL Logging Utilities. For more information about configuring tracing for the .NET CIL, see Logging and tracing (.NET).
HKEY_LOCAL_MACHINE\SOFTWARE\Cisco Systems\CTIOS Tracing
These settings are defined as follows:
Parameter |
Description |
Optimal Value |
---|---|---|
FlushIntervalSeconds |
Maximum number of seconds before the trace mechanism transfers data to the log file. |
30 |
MaxDaysBeforeExpire |
Maximum number of days before a log file is rolled over into a new log file regardless of the size of the file. |
7 |
MaxFiles |
Maximum number of log files that can exist in the log file directory before the logging mechanism starts overwriting old files. |
5 |
MaxFileSizeKb |
Maximum size of a log file in kilobytes. When a log file reaches the maximum size, a new log file is created. |
2048 |
TraceMask |
Bit mask that determines the categories of events that are traced. |
0x40000307 |
Java CIL Logging Utilities
The Java CIL provides a different logging facility than the C++ CIL. This gives the customer application more flexibility in how trace messages are handled. It also limits the number of special privileges the browser would need to give the applet using the CIL; the Java CIL only needs to access the network and not the file system. For that reason, the Java CIL does its tracing through the firing of special events called "LogEvents" that the custom application can trap and handle in however way it sees fit.
The Java CIL provides the following objects for logging as part of the utilities package.
ILogEvents
This interface must be implemented by a class interested in receiving Java CIL LogEvents. It has only one method.
void processLogEvent(LogEvent event)
LogEvent
A custom application that is interested in receiving LogEvents receives an object of this type whenever a log message is generated. This class extends the Java "EventObject", and has one public method.
Method |
Description |
getDescription |
Returns the text description to write somewhere. |
Syntax
String getDescription()
Logger
A custom application that is interested in firing or handling its own LogEvents can create an instance of this class.
Method |
Description |
Logger |
Public constructor of the Logger object. |
Trace |
Lets the custom app fire a LogEvent. |
GetTraceMask |
Gets the trace mask. |
IsTraceMaskEnabled |
Determines if a certain trace mask is set. |
addLogListener |
Subscribes to receive LogEvents. |
removeLogListener |
Unsubscribes from receiving LogEvents. |
Syntax
Logger() int Trace(long nMsgTraceMask, String message) long GetTraceMask() boolean IsTraceMaskEnabled(long nMsgTraceMask) void addLogListener(ILogEvents logEvents
where logEvents implements the ILogEvents interface.
void removeLogListener(ILogEvents logEvents)
LogEventsAdapter
This is a wrapper class around the Logger facility. A custom application that is interested in tracing but does not want to implement its own ILogEvents interface can create an instance of this class. The adapter class provides two constructors, a default one that automatically logs to the Java console and one that takes in an output filename.
Method |
Description |
LogEventsAdapter |
Public constructor. |
startLogging |
Starts receiving LogEvents. |
stopLogging |
Stops receiving LogEvents. |
processLogEvent |
Handles a LogEvent. |
finalize |
Does some cleanup. |
Syntax
LogEventsAdapter()LogEventsAdapter(String fileName) void startLogging() void stopLogging() void processLogEvent(LogEvent e) void finalize()
Logging and tracing (Java)
The Java CIL tracing mechanism behaves differently from that of the COM and C++ CILs. The Java CIL does not automatically create a log file and trace to it. You must develop the custom application to create and maintain the log file.
The Java CIL provides classes that allow you to write tracing messages from CTI applications. You can create a class that implements ILogListener, register it with the LogManager, and write the trace events to a log file.
The Java CIL also includes the LogWrapper class, which implements the ILogListener interface and provides a default logging mechanism.
The LogWrapper class has three constructors:
- LogWrapper() - Creates a new LogWrapper object that writes tracing messages to System.out.
- LogWrapper(string sFileName) - Creates a new LogWrapper object that writes trace messages to the file specified in sFileName.
- LogWrapper(string sFileName, long iMaxSize, int iArchives, int iExpires, int iFlushIntervalMs) - Creates a new LogWrapper object that traces to the file specified in sFileName and sets all the tracing properties provided:
If a developer deploys an application and then wants to debug it in the field, they need a way to change the trace mask from the default level if necessary to provide more information for debugging.
Note | You also need to provide a way to adjust the trace mask at runtime. If you encounter problems, Cisco personnel need to see this log file to assist you with your problem. |
For more information about the LogWrapper class and its associated methods, see the Java CIL Javadoc file.
Logging and tracing (.NET)
The .NET CIL tracing mechanism behaves differently from that of the COM and C++ CILs. The .NET CIL does not automatically create a log file and trace to it. You must develop the custom application to create and maintain the log file.
The .NET CIL provides classes that allow you to write tracing messages from CTI applications. Custom applications can either create their own logging mechanism or use the default logging mechanism provided in the .NET CIL.
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.
Log Trace Events with LogWrapper Class
Custom Logging Mechanism
The LogManager class within the .NET CIL implements all CIL logging functions. This singleton class has only one instance of LogManager, which provides a global point of access. The LogManager object defines a LogEventHandler delegate that custom applications must implement:
public delegate void LogEventHandler(object eventSender, LogEventArgs args);
Log Trace Events with 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 sends trace events to the method that you pass to the LogEventHandler. In the following example, the LogManager sends trace events to the ProcessLogEvent method created in Step 2. m_log.AddLogListener(new LogManager.LogEventHandler(ProcessLogEvent));
|
Trace Configuration (Java and .NET)
For the Java and .NET CILs, you can configure tracing either programmatically by using the LogWrapper class or by editing the TraceConfig.cfg file. Settings in TraceConfig.cfg do not take effect until LogWrapper.ProcessConfigFile is called. Your application must call ProcessConfigFile if you have edited the configuration settings in the TraceConfig.cfg file.
The All Agents Sample .NET code in the .NET CIL includes a sample TraceConfig.cfg file and shows you how to process that file.
Log file configuration settings are defined as follows:
Parameter |
Description |
Optimal Value |
---|---|---|
NumberDaysBeforeFileExpired |
Maximum number of days before a log file is rolled over into a new log file regardless of the size of the file. |
1 |
NumberArchivesFiles |
Maximum number of log files that may exist in the log file directory before the logging mechanism starts overwriting old files. |
5 |
FileMaxSize |
Maximum size of a log file in kilobytes. When a log file reaches the maximum size, a new log file is created. |
2048 |
TraceMask |
Bit mask that determines the categories of events that are traced. |
0x40000307 |