Filter löschen
Filter löschen

How can I create a log file for my compiled standalone application to debug runtime issues?

52 Ansichten (letzte 30 Tage)
I'm using MATLAB Compiler to build a standalone application and want it to generate a log file capturing the Command Window output that I would usually see in MATLAB. This will help me debug the standalone application when errors or unexpected behavior occur. Is this possible?

Akzeptierte Antwort

MathWorks Support Team
MathWorks Support Team am 30 Aug. 2024
Bearbeitet: MathWorks Support Team am 30 Aug. 2024
Since MATLAB R2013b, the Application Compiler app includes an option to specify a log file name. You may follow the steps below to enable this log file:
  1. Open your Application Compiler project.
  2. Expand the "Additional Runtime Settings" section.
  3. Check the "Create log file" option.
  4. Enter the desired log file name in the "Log File" field.
  5. Compile the standalone application.
After following these steps, a log file with the specified name will be created in the current working directory when the standalone application is launched.
When using the "mcc" command to compile the application, use the "-R" and "-logfile" flags:
mcc -m myScript.m -R '-logfile,mylog.txt'
For R2013a and Earlier Releases:
For MATLAB R2013a and earlier, use the "diary" command to generate a log file for a standalone application. Include the following line of code in your program:
diary on
When the diary is enabled, the application will create a log file that includes all of the commands executed by the standalone application and all of the text that is displayed in the Command Window. Please note that any commands executed before the diary is enabled will not be logged.
When the above code is compiled into the standalone application, the application logs will be written to a file named "diary" located in the current working directory.
  3 Kommentare
dpb
dpb am 30 Aug. 2024
ADDENDUM: It turns out to have been a figment of the display that the opening of the "Additonal runtime settings" section didn't change the focus of the screen to show the check boxes highlighted above but was and remained with the blue header line identically at the bottom of the screen so there appeared to be no effect whatsoever to opening the additonal settings...I eventually figured that out but forgot to come back and either edit the Q? comment or explain the reason asked...
dpb
dpb am 31 Aug. 2024
ADDENDUM SECOND:
NOTA BENE: One cannot specify a directory location for the log file if using the above user interface, there's a too-strict check on what can be entered as a legal file name that excludes the '\' and ':' characters as well as other truly illegal characters.
This is a problem since the typical user of the compiled app almost always will not have administrator privileges and so the install directory is unwritable and the log file will not be created.
The solution/workaround is to not check the 'create log file' box here but use the -R option as "additional parameters to mcc" which will accept the path.
As I noted in another comment on the log file issue, the way this is handled is not well with the default behavior.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Java Package Integration finden Sie in Help Center und File Exchange

Produkte


Version

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by