Starting with Adaptive Server Enterprise ODBC Driver 15.7 ESD #4, you can dynamically enable or disable the application logging during application execution by setting the 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/path.
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.