Search code examples
jythonmaximo

Maximo Automation script logs on script crash


I'm working with a Jython automation script in Maximo. I'm seeing the output of my print statements in the MXServer logs when the script exits correctly, but none of my print statements make it into the logs if the script crashes - even the print statements that execute before the script crashes. Is this just how Maximo works, or is there some way of seeing those print statements when the script crashes? It's very difficult to debug why the script is crashing if I can't see my print statements.


Solution

  • That is the way the scripting engine works in Maximo. If it can't exit cleanly, it won't dump the output it had received so far (or be able to grab the output stored in the executing script). This is a primary reason why you should be using logging statements instead of print statements (there are some others too, like being able to change the logging output level; this parallels the advice that you should never use System.out.println and should use a logger instead). Logging statements from the script will still print out as the script runs, even if the script does not exit cleanly (or has not exited at all yet).

    As of Maximo 7.6.0.something they even added some logging helper functions to the special service object that scripts get. You can call service.log_debug, service.log_info, etc. to log out at the respective level to a premade logger.