Parameters
logname | name of the log, not case-sensitive |
pathname | name of the file, the log is stored in |
format | log line format |
Since version
7.0
Function value
This function returns TRUE if successful, FALSE if an error occurs. The possible error may occur because a log of the specified name already exists, because the server couldn't create or open a file on the specified path or because low memory.
Description
This function creates a new log and assigns it the logname name, which can be used in the _sqp_trace
function for setting the logging activity of the SQL server. THe log is written into the file specified in the pathname parameter. If pathname is empty, the file will be created in the same folder as the server basic log, with the logname name and the suffix txt
. If the specified file already exists, the log will be appended after the file contents.
The basic server log (designated with empty name) is defined automatically on server startup and you don't need to enable it by calling this function.
A log may be created only by the configuration administrator - see Administering the SQL server.
If the format parameter is empty, the log will have the standard format. You may set different format by specifying a formatting character string in the format parameter. The formatting string must abide the rules of the sprinf
C function - the positions where variable information should be placed must be marked like the following:
%
d - date, day and month
%D
- date, day, month and year %t - time, ho
ur and minute
%T - time, hour, minute and second %s - situation mark (one letter) %u - name of the user or working process %c - client number %e – unique session number (client - server connection)
%
a – name of an opened scheme
%m - message text
The standard log has this format : "%d %t %s %u %m
". You may specify at most 10 such parameters in the formatting string. The maximum formatting string length is 50 characters.
See
Example:
Enable the SQL commands logging and client logging into the DEBUGLOG auxiliary log upon server startup:
PROCEDURE _ON_SERVER_START();
BEGIN
CALL _sqp_define_log('debuglog','c:\aux\debuglog.log','%d %t %s %a %u %m');
CALL _sqp_trace(TRACE_LOGIN, '', '', 'debuglog', 3);
CALL _sqp_trace(TRACE_SQL, '', '', 'debuglog', 3);
END