question

Serge A avatar image
1 Like"
Serge A asked Phil BoBo commented

Redirect system console to file

Is there a way to redirect system console and output console messages to a file/files?

I have to debug a model where in a long-running Experiment some replications may randomly crash or get stuck. Unfortunately, these events are not reproducible (different replications may fail on a different Experiment Run). I'd like to see what was there in the system console just before the crash, to know what component/DLL to blame.

FlexSim 20.0.8
experimenterflexsim 20.0.8system consoledebugoutput console
· 2
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

Phil BoBo avatar image
2 Likes"
Phil BoBo answered Phil BoBo commented

In a child experiment, the system console output is written to a std::stringstream. When the experiment finishes, the contents of the stringstream are written to a node and passed back to the parent.

You can get the text of the stringstream programmatically using applicationcommand("getconsoletext", 2), but as you noted, if the program is crashing or in an infinite loop, you don't have a callback opportunity to execute this function.

You might be able to get some crashing information if you add an exfslogfile.txt to your FlexSim documents directory and/or C:\exfslogfile.txt. There's old code in the engine that prints exceptions and crashing info to those files if they exist, but we haven't recently tested or used them to know whether they will be helpful or not.

· 2
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.