Adaptive Server Enterprise ODBC Driver 15.7 introduced the application logging without an ODBC driver manager tracing feature. See “Logging without ODBC Driver Manager tracing”. The application logging can be enabled (or disabled) for the duration of application execution.
ESD #4 extends this support by allowing you to dynamically enable or disable the application logging during application execution by setting the new SQL_OPT_TRACE environment attribute. Valid values are 0 (default) to disable or 1 to enable.
// enable logging SQLSetEnvAttr(0, SQL_OPT_TRACE, (SQLPOINTER)1, SQLINTEGER); // disable logging SQLSetEnvAttr(0, SQL_OPT_TRACE, (SQLPOINTER)0, SQLINTEGER);
Dynamic logging is enabled and disabled globally and affects all connections regardless of when they were opened and whether they are part of the environment handle used to set SQL_OPT_TRACE.
By default, the log is written to the sybodbc.log file in the current directory. Use the SQL_OPT_TRACEFILE environment attribute to set a different file or file path.
SQLSetEnvAttr(0, SQL_OPT_TRACEFILE, (SQLPOINTER) “logfilepath”, SQL_NTS);
Setting the LOGCONFIGFILE environment variable or registry value enables logging for the entire duration of application execution and overrides SQL_OPT_TRACE.
If an ODBC Driver Manager is being used, setting SQL_OPT_TRACE turns on the Driver Manager tracing and has no impact on driver tracing.
The client application can use a null handle when linking directly against the driver or an allocated handle when using Driver Manager tracing.
log4cplus configuration file cannot be used with SQL_OPT_TRACE.