Logging MathLM
By default, MathLM generates all log files in the W3C Common Logfile Format used by web servers such as Apache. However, you can customize the format by using the option -logformat. This option takes a string argument that specifies the format in which server messages are displayed. The string contains a series of commands of the form %var#, where
For example, %y1 means that the year is displayed in two-digit format (e.g., 22), while %y2 displays the year in four-digit format (e.g., 2022).
In addition to the %var# commands, the string can also include plain text such as brackets, dashes, quotation marks, and arbitrary comments. The text can be used to include comments and separators in the server messages for formatting purposes. All text included in the string appears literally in the server message with the following two exceptions: use %q to include a double quote ("), and use %% to include a percentage sign (%).
You must specify the type of messages that should be logged using the option -loglevel, as explained in "Launching MathLM".
Here is a list of variables that can be included in the string, along with their numeric values and formats.
Variable Name | Possible Values | Description | |
%h#
| 1 – IP address
2 – hostname
3 – fully qualified domain name | host | |
%u#
| 1 – user ID
2 – username | user | |
%d
|
numeric [1...31]
| day of month | |
%w#
| 1 – numeric [ 1 ... 7 ]
2 – abbreviated [ Sun ... Sat ]
3 – verbose [ Sunday ... Saturday ] | day of week | |
%m#
| 1 – numeric [ 01 ... 12 ]
2 – abbreviated [ Jan ... Dec ]
3 – verbose [ January ... December ] | month | |
%y#
| 1 – two-digit [ 23 ]
2 – four-digit [ 2023 ] | year | |
%t#
| 1 – twelve-hour (10:20:15)
2 – twenty-four-hour (22:20:15)
3 – GMT offset (-0500) | time | |
%e#
| 1 – numeric
2 – verbose | event | |
%r#
| 1 – numeric
2 – verbose | response |
MathLM logging variables.
Note: All Windows clients on a network have the same user ID (set to the number 65535 by default). Hence, the user ID setting is only meaningful for clients running Unix, Linux, or Mac OS X.
Note: To use the GMT offset format (%t3), you must also use the -localtime option when starting MathLM.
Running the command mathlm -logfile log.txt, without the option -logformat, generates messages in the default format. An example of messages in the default format, as contained in log.txt, follows.
hostname.domain.com - username [01/Apr/2023:22:01:00] "MathLM 13.1 executable launched" ".\mathlm" -
hostname.domain.com - username [01/Apr/2023:22:01:00] "Verbosity level specified" "1" -
hostname.domain.com - username [01/Apr/2023:22:01:00] "Logging verbosity level specified" "3" -
hostname.domain.com - username [01/Apr/2023:22:01:00] "Hostname" "hostname.domain.com" -
To specify the Common Logfile Format manually, you must specify this string as the value of the -logformat option, as in the following command. The messages generated by this command are in the same format as the previous example.
By default, time is displayed in GMT. If you want local time to be displayed instead, you must use the -localtime command-line option with either the %t1 tag or the %t2 tag. The %t3 tag should not appear in the format string if you want local time to be displayed.
An example of server messages in this user-specified format, as contained in log.txt, is displayed here.
192.168.1.9 - username [04-16-23: 04:32:51 PM] "MathLM 13.1 executable launched" ".\mathlm" -
192.168.1.9 - username [04-16-23: 04:32:51 PM] "Default (Common Logfile Format) log format specified" "%h1 - %u2 [%m1-%d-%y1: %t1] %q%e2%q %q%r2%q -" -
192.168.1.9 - username [04-16-23: 04:32:51 PM] "Verbosity level specified" "1" -
192.168.1.9 - username [04-16-23: 04:32:51 PM] "Logging verbosity level specified" "3" -
192.168.1.9 - username [04-16-23: 04:32:51 PM] "Hostname" "hostname.domain.com" -
Note: Server messages in IPv6 networks will display IPv6 addresses automatically, with no additional configuration required.