Using TTClasses Logging
TTClasses has a logging facility that allows applications to capture debugging information. TTClasses logging is associated with processes. You can enable logging for a specific process and produce a single output log stream for the process.
TTClasses supports different levels of logging information. See the example in Acknowledging XLA Updates Without Using Transaction Boundaries for more information about what is printed at each log level.
Log level TTLOG_WARN
is very useful while developing a TTClasses application. It can also be appropriate for production applications because in this log level, database query plans are generated.
At the more verbose log levels (TTLOG_INFO
and TTLOG_DEBUG
), so much log data is generated that application performance is adversely affected. Do not use these log levels in a production environment.
Although TTClasses logging can print to either stdout
or stderr
, the best approach is to write directly to a TTClasses log file. The example below demonstrates how to print TTClasses log information at log level TTLOG_WARN
into the /tmp/ttclasses.log
output file.
Note:
TTClasses logging is disabled by default.
ofstream output;
output.open("/tmp/ttclasses.log");
TTGlobal::setLogStream(output);
TTGlobal::setLogLevel(TTLog::TTLOG_WARN);
First-time users of TTClasses should spend a little time experimenting with TTClasses logging to see how errors are printed at log level TTLOG_ERROR
and how much information is generated at log levels TTLOG_INFO
and TTLOG_DEBUG
.
See TTCGlobal Usage for more information about using the TTGlobal
class for logging.