How to specify file path with -logfile flag for my standalone application created with MATLAB Compiler?

7 visualizzazioni (ultimi 30 giorni)

If I only specify a file name, for example 'log.txt', the log file is saved in the same folder as the application exe file. How can I save it in a different folder?

Risposta accettata

MathWorks Support Team
MathWorks Support Team il 17 Mag 2024
mcc -R '-logfile,log.txt' Main.m % log.txt is saved in the application folder
mcc -R '-logfile,c:\temp\log.txt' Main.m % c:\temp folder has to exist, otherwise log.txt won't be created
As the above example shows, you can specify file path in the file name. But please note the file path must be existing already. 
If you don't know if the path will exist on your end users' machine, one workaround is you can use "mkdir" function in your application code and save logfile to the directory you have created. But still the first time when the app runs the log file won't be created. The folder will be created with mkdir. For future runs of the app the log files can be saved in the folder.
  1 Commento
dpb
dpb il 29 Ago 2024
Is there anyway to change the log file location programmatically or is that fixed in stone by the location determined from the -R location at compile time? Can/is an environment variable reference expanded (one presumes not)?
This seems a very crude technique relying on outside intervention and that it doesn't work well at all with the default installation choice being unwriteable to a non-administrative account since virtually all users who would be installing a packaged app will not have admin privileges normally and even to run the app as administrator would have to call their IT support to provide them that approval (which in the institutions of which I'm familiar, they wouldn't be willing to do that, anyway).

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su File Operations in Help Center e File Exchange

Tag

Non è stata ancora inserito alcun tag.

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by