Debugging AppleScript: print to a file

less than 1 minute read

Debugging AppleScript is easy when you work with the script editor, simply use log to print out anything in the console. However, after you compiled it to an app, this cannot work anymore.

I find there are several ways to do it in this thread. The two approaches that work best for me are:

  1. Use logger to log to the syslog. E.g.,
do shell script "logger -t 'AS DEBUG' " & myObj

However, I don’t know why sometimes this is not logged. So I will use the following:

  1. Echo to file
do shell script "echo " & quoted form of (myObj as string) & ¬
    " >> ~/Desktop/as_debug.txt"