Program Logging

NetPhantom provides means to create custom log entries directly from an application. This allows for a very flexible way of collecting information from the clients. The log is run as a single server instance and is accessed by clients through applications implementing the program logging functionality.

The log is controlled directly in Java or REXX code. The following commands are available.

   StartLog() - Start the logging. All entries generated after this will be logged.

   StopLog() - Stop the logging. Entries generated after this will be ignored.

   LogMsg('Message to be put in log') - The structured string to be put in the log.

   RotateLog() - Force the log to be rotated, if configured as possible to rotate.

All commands return 0 if successful. 1 indicates a problem; logging not active for LogMsg or logging not configured for all commands.

Please note that this means that starting and stopping the program logging means that this will effect all users/applications running on the server. There is only one instance of the program logging function on the server. The StartLog/StopLog/RotateLog commands should be seen as management tools.

Variable substitution

The following variables are available when composing the message.
Variable
Argument
Format
IP address/IP #
%A
IP address or IP number
Date
%D
Locale (configured for NetPhantom) date string
Time
%T
Locale (configured for NetPhantom) time string
Client session
%C
Number denoting session ID
Host ID
%H
A-Z, host ID
User ID (host)
%U
String
Panel name
%P
String
Thread name
%N
String
Thread ID
%I
Number
Application name
%B
String denoting the application name in NetPhantom
Java version
%J
String
OS name
%O
Number denoting Windows version
NetPhantom Client version
%V
Version number (build number)

All variables are converted into string format to be used in when composing the structured message.

    LogMsg('%D %T - Application: %B, Panel: %P, Session: %C; other text ...')

(The arguments can be escaped with an extra % sign; "%%P" is converted to "%P")

Configuration

To enable the program logging functionality, the following line should be entered in the [Base] section of the server.ini file of the server to host the logging:

    programLogFile=name.log

or

   programLogFile=/example_path/name.log

In the first case, the log file will be located in the installation directory of the NetPhantom Server. In the second case, the log file will be placed in the path indicated (under Windows: C:/example_path/).

If the logs should be automatically rotated, there are two alternatives:

   programLogRotate=Date

This will create a log file named yy-mm-dd-name.log (example: 11-07-22-name.log) in the alternative path, if indicated. A new log with a new name will be automatically created when the dates shift and new log entries will be put there.

Second alternative:

    programLogRotate=300

This will create two log files: name1.log and name2.log. They will be rotated when the size of the file reaches the indicated 300 (KB). Any entries remaining in the file that is rotated to will be deleted.

The two rotation modes are mutually exclusive. If both are configured, the rotate date alternative is used. Programmatically rotating the log files is only possible in the case where size rotation is configured.

The encoding of the log entries when they are written to file can be configured.

    programLogEncoding=8859_1

If encoding is not configured, 8859_1 is used by default.