File Logging

Using a set of methods in the Java API set, you can control file logging, and also set up rolling log files.

Rolling Log Files
 With rolling log files enabled, you specify the size of each log file and the number of log files to be maintained. When the current log files reach their maximum configured size, logging is rolled over to a new log file. The number of log files is also configurable.

In the C API, logging configuration is specified by two functions, one that specifies log file level, and another function that controls rolling log file configuration.

Java API

The FileLogOptions class in the Java API provides the following methods:

setFile
 Specifies the log file to be used.
public abstract FileLogOptions setFile(java.io.File logFile)

The logFile parameter specifies the name of the log file.

setLimit
 Specifies the file size limit for the log file (in bytes).
public abstract FileLogOptions setLimit(int limit)

The limit parameter sets the file size limit. The default value (-1) specifies unlimited) file size.

The count parameter specifies the total number of log files.

setAppend  
Specifies whether log fils can be appended to.
public abstract FileLogOptions setAppend(boolean append)

The append parameter specifies whether to append to existing files.

setLogLevel
 Specifies the log level to be used.
public abstract FileLogOptions setLogLevel(LogLevel level)

The level parameter specifies the log level to be used. You can specify the following values:

  • ERROR - Error level logging output of errors
  • FATAL - Error level logging of fatal errors
  • FINE - Outputs debug information
  • FINER - Outputs debug information
  • FINEST - Outputs detailed debug information,
  • INFO - Outputs debug information. The default log level is INFO.
  • NONE - Specifies no logging
  • WARN - Warning level logging outputs warnings

Querying Log Settings

The Java API includes a set of methods that query the log file settings:

getFile
 Returns the log file name.
getLimit
Returns the configured log file size.
getFileCount
 Returns the configured number of log files.
isAppend
 Indicates whether appending to log files is configured
getLogLevel
 Returns the configured level of file logging.

C API

The C API provides two functions that control logging:

tibas_EnableFileLogging() 
Specifies the log directory, the log file name, and the log level to be displayed.
tibas_status tibas_EnableFileLogging(
    const char* logDir,
    const char* fileName,
    tibas_logLevel logLevel);
tibas_EnableFileLoggingEx()
  Sets the values in the tibasfileLogOptions structure, which controls the values for rolling log file.

The tibasFileLogOptions structure is defined as follows:

struct _tibasFileLogOptions {
    const char* filePath;
    tibas_logLevel level;
    tibas_int limit;
    tibas_int fileCount;
    tibas_boolean append;
};
Related reference