Menu
Simba Technologies
Simba Technologies

SimbaEngine X SDK 10.1.3
Developing Drivers for Data Stores Without SQL

Implementing Logging

The SimbaEngine X SDK includes comprehensive logging functionality that you can use when developing and troubleshooting your driver.

For information on how to turn on logging in the sample drivers, see Enable Logging in the 5 Day Guides at http://www.simba.com/resources/sdk/documentation/.

For information on logging to Event Tracing for Windows (ETW), see How to Log to Event Trace for Windows (ETW).

The SimbaEngine X SDK enables multiple logger objects logging to separate files: one for the single IDriver instance, and one for each IConnection instance. This allows for easier debugging of threading issues, while still allowing for logging of issues that happen before a connection is established. If only one central log is needed, then child IConnection objects can return the parent IDriver log instance to have all logging calls focus on one ILogger.

The ILogger has a default implementation in DSILog, each of which logs to a file. There are several functions to log messages at varying levels of importance as needed. The DSILog allows for filtering of logging messages based on both log level and namespace, enabling you to narrow logging to suspect areas of your DSII. If the default DSILog does not provide enough functionality, then you may choose to create a full implementation of ILogger directly from the interface that provides the functionality that you need.

Log Settings

There are three settings that affect logging by default:

  • LogLevel – Used to set the level of logging that is performed. Valid values are:
    • 0 or “Off”
    • 1 or “Fatal”
    • 2 or “Error”
    • 3 or “Warning”
    • 4 or “Info”
    • 5 or “Debug”
    • 6 or “Trace”
  • LogPath – Set the path that the default logging implementation will create the log files in. Defaults to the current working directory.
  • LogNamespace – Filters the logging based on the namespace/package that the messages are coming from. For instance, the value “Simba” will filter all logging messages to namespaces starting with “Simba” such as “Simba::Support”.

The settings are read from the registry at HKLM\SOFTWARE\<OEM NAME>\Driver for both SimbaODBC and Simba.NET, while they are read from the connection string for SimbaJDBC.

Hiding Sensitive Information in the Log Files

The SimbaEngine X SDK does not log the value of the connection parameters username (UID) and password (PWD). Instead, the values are logged as asterisks (****). The DSIConnection::IsSensitiveAttribute() method determines whether or not the value of a connection parameter should be logged. The IsSensitiveAttribute() method is called by the ConnectionSettings class when a connection is established.

Example

If you enter a username and password when connecting to the MyQuickstartDSII driver, the resulting log file will contain the strings "PWD" = "***" and "UID" = "***", rather than the actual username and password.

Your custom ODBC driver can specify additional connection parameters that should not have their values logged in plain text. To do this, override DSIConnection::IsSensitiveAttribute() in your Connection.cpp class.

For example, in the following code, the values of the connection parameters Secret1 and Secret2 will be logged as asterisks (*****):

bool QSConnection::IsSensitiveAttribute(const simba_wstring& in_attribute)
{
  if ((in_attribute.IsEqual("Secret1")) ||(in_attribute.IsEqual("Secret2")))
  {
    return true;
  }

  return DSIConnection::IsSensitiveAttribute(in_attribute);
}

 

Logging in the Java DSI

The Java SimbaEngine X SDK includes a helper class called LogUtilities to help you implement logging functionality. This class provides a copy of many of the functions that exist in ILogger, but the functions take an ILogger instance and do not take the namespace or class names from which the logging call originates. Instead, it uses reflection to determine that information, easing use of the logger.

Logging in the DotNet DSI

The dotNet SimbaEngine X SDKincludes a helper class called LogUtilities to help you implement logging functionality. This class provides a copy of many of the functions that exist in ILogger, but the functions take an ILogger instance and do not take the namespace or class names from which the logging call originates. Instead, it uses reflection to determine that information, easing use of the logger.

Simba.NET Specific Features

Note that there is an extra setting for Simba.NET to provide logging if an error occurs before a DSI DLL is loaded:

  • PreloadLogging – Set to 0 (off) or 1 (on) to log to the file InitialDotNet.log. Once a DSII DLL is loaded, the DSI ILogger will be used.

 

Related Links

Enable Logging in the Data Engine

How to Log to Event Trace for Windows (ETW)

Enable Logging in the 5 Day Guides at http://www.simba.com/resources/sdk/documentation/.

http://www.simba.com/resources/sdk/knowledge-base/enable-logging-in-odbc/

http://www.simba.com/resources/sdk/knowledge-base/simbaengine-logging/