Skip to main content

Writing Scripting Toolkit logs to the console

The Foundation layer defines a logger with the name GDL that can be used to capture logs about the requests made to Granta MI. To use this logger, first fetch the logger object either via the get_foundation_logger function, or by using the Python logging module directly.
Next, configure and attach a StreamHandler to the logger. A StreamHandler writes log messages to stderr.
Finally, set the logger level to DEBUG to ensure all messages are displayed. The log level defines the minimum log level to be handled by this logger.
To test that the logging has been set up successfully, perform some Scripting Toolkit operations. The log messages generated by the Foundation Layer are shown on the console or in the notebook, depending on how this script is executed.
Previous cell output:

Writing Scripting Toolkit logs to a file

If you would like to write logs to disk, you can use a FileHandler. In this example, use a timestamp to define a unique file name for each execution of the script.
To test that the log files are being generated, perform some more Scripting Toolkit operations. The log messages will be available both on the console (or in the notebook) and in a file on disk.
Previous cell output:
If required, you can also define additional loggers for your own log messages, which may have different handlers and may log at different levels. For more details on managing logging, including additional handler types with more advanced file management capabilities, consult the Python logging documentation.

Additional Scripting Toolkit logging

The MI Scripting Toolkit underlying C libraries also perform their own additional logging separate to the Python logging. These logs can be found in the following locations:
  • Windows: %LOCALAPPDATA%\Granta Design\MIScriptingToolkit
  • Linux: ~/.appdata/Granta Design/MIScriptingToolkit