Download Server Session Log

This article explains how to obtain the session log file of a solver session ran on an AIMMS PRO on premise.

Note

The AIMMS log files are created by AIMMS staff and designed to be interpreted by AIMMS staff. The meaning of log entries may not be obvious. An error or warning message in the log file does NOT necessarily indicate a problem in the application.

Running example:

The AIMMS project that contains the example can be downloaded here

This example contains a small transport problem as an example: transporting pellets of bottled water.

Operating the example

After publishing the application, you can (by pressing the three buttons in sequence):

../../_images/solved-downloaded-session-log.png
  1. Solve the mathematical program.

  2. Determine the session id of the solver session just ran.

    In the example supplied, the session id of the last solver session ran is obtained via

    1sp_serverSession := pro::session::CurrentSession();
    

    The procedure pro::sessionmanager::ListSessionSinceDate also provides a set of session id’s.

  3. Download the session log. As the (WebUI) data session is running locally on the host of the AIMMS PRO server, it has access to this session log file.

Explaning the download code

AIMMS PRO on premise stores the session logs in the folder %AIMMSPRO_DATADIR%\Log\Sessions. The session names are part of the names of the log file.

Perhaps interesting is that using AIMMS PRO 2.34 and newer, session logs are named such that it is clear from the session name:

  1. the application

  2. the type of session (solver, data, verify)

  3. the moment started

The above is sufficient to write code to copy the session log first in the project folder, and then to download it to you download folder. This code detailed in the next section, and in the last section it is explained how to integrate in your own application.

Tip

As an admin you can trigger the elaborate naming of session log files by pressing the buttons Restore all to defaults and Save settings in the tab Configuration > Log Management of the AIMMS PRO portal.

As a first step, the complete filename of the session log is determined.

 1EnvironmentGetString(
 2    Key   :  "AIMMSPRO_DATADIR",
 3    Value :  sp_proDataDir);
 4sp_sessionLogDir := sp_proDataDir + "\\Log\\Sessions";
 5
 6DirectoryGetFiles(
 7    directory       :  sp_sessionLogDir,
 8    filter          :  "*.log",
 9    filenames       :  sp_filenames(i_fileNumber),
10    recursive       :  0);
11
12ep_logFileNo := first( i_fileNumber | findString(sp_filenames(i_fileNumber), sp_serverSession ) );
13if ep_logFileNo then
14    sp_baseSessionLogFilename := sp_filenames(ep_logFileNo) ;
15    sp_originalSessionLogfileLocation := sp_sessionLogDir + "\\" + sp_baseSessionLogFilename ;
16else
17    sp_originalSessionLogfileLocation := "" ;
18    raise warning "session log file for " + sp_serverSession + " not found." ;
19endif ;

Remarks on the above code:

  1. Line 1-4: Obtain the session log folder.

  2. line 6-10: Get a list of all session log files.

  3. Line 12: Determine the log file that contains the session id as part of its name.

  4. Line 14,15: Construct full path of the log file for the session at hand.

As a second step, copy the file to the project folder, then in the download template.

 1pr_getSessionLogFile(sp_serverSession, sp_baseSessionLogfilename, sp_originalSessionLogfileLocation);
 2fileLocation := sp_baseSessionLogfilename ;
 3FileCopy( sp_originalSessionLogfileLocation, fileLocation );
 4
 5sp_FileProcessSpecificFileName := webui::GetIOFilePath(FileLocation);
 6if fileLocation <> sp_FileProcessSpecificFileName then
 7    fileCopy( fileLocation, sp_FileProcessSpecificFileName );
 8endif ;
 9
10StatusCode := webui::ReturnStatusCode('CREATED');
11StatusDescription := "Nice.";

Remarks on the above code:

  1. Line 1: obtain the filename of the solver session log from the session id (see the first step discussed above).

  2. Line 3: Copy the session log file to the project folder

  3. Line 7: Copy the session log file to the process specific temporary folder. This is the folder where files are downloaded from.

Integration in your own application

The code explained and demoed above is contained in a separate section named: Download server session log of download offered above. See Export code to another project for copying the code to your project. Once you’ve copied the code, you need to add the following widgets:

  1. button to obtain the session id,

  2. download button to actually download the session log file.