0

How can I get the output written to stderr and stdout from an app that has been installed by .dmg, and is opened by double-clicking its app icon in the /Applications directory?

(I can see the output when I call the app in a terminal by using the path /Applications/MyAppName.app/Contents/MacOS/myappname, but this doesn't help since the the app behaves differently when I double-click the icon.)

4
  • 1
    How an app is installed (i.e. dmg) is irrelevant to how it generates error messages and logs them. It my send the output to the standard system log or it may have a log all on it's own. How it behaves based on how it's launched is also a function of the app, not the system so that too would have to come from the dev. What's the application (not that there's any guarantee we'd know the inner workings of said app)? What version of macOS? Without info like this it tough to even hazard a guess. – Allan Jun 9 '20 at 17:28
  • I'm using 10.15.4 Catalina. It's I who made the app actually, and I'm trying to debug. So I'm trying to print error output, including getting output from any Python exceptions that are raised. I've been iterating with printing debug output to a file in my home directory, and then I will catch the exception and append it to that file as well. It would be nice if there was a file that all stdout and stderr were written to for this type of double-clicked app. Perhaps it all just goes to /dev/null ? – krumpelstiltskin Jun 9 '20 at 17:39
  • Error handling is done entirely at your discretion. It won't go to /dev/null unless you tell it to. Then again, you have to have the app generate a log to begin with. Any errors generated (i.e. something that causes the system to not like what's happening) would be sent to the console. If it's an issue with the app itself (i.e. the user put in the wrong number of arguments), that error would have to be generated by you and written somewhere. – Allan Jun 9 '20 at 17:51
  • OK... so I had checked the console and didn't find anything. There was output associaed with my program, but no exceptions or error message besides an "unsigned" error. Would a Python exception be displayed in console? – krumpelstiltskin Jun 9 '20 at 18:03
1

This answer is from 2013 but is mostly still relevant.

Prior to Mountain Lion, all processes managed by launchd, including regular applications, had their stdout and stderr file descriptors forwarded to the system log. In Mountain Lion and above, stdout and stderr go nowhere for launchd managed applications. Only messages explicitly sent to the system log will end up there.

If you're writing an application and would like some output to show up in the console, then adopt an API built on syslog(3) or asl(3) instead. NSLog is one such API, and it has the advantage of logging to stderr too so you can easily see your output no matter how you've launched your application. If you'd like that functionality but want to use asl or syslog directly then you'll want to look in to the ASL_OPT_STDERR option to asl_open, and the LOG_PERROR option to openlog respectively.

Basically, when you double-click an app (same as /usr/bin/open /Applications/SomeApp.app) there is no stdout/stderr. The dev is expected to send any relevant output/errors to the available logging APIs such as NSLog.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .