0

Or, how to log from an AppleScript (saved as application) and/or view the Event Log?

None of the AppleScript's log statements can be found. I have tried adding the following to the launchd plist:

<key>StandardOutPath</key>
<string>/tmp/theProgram.log</string>
<key>StandardErrorPath</key>
<string>/tmp/theProgram_error.log</string>

after which, the files were happily created, but remain empty. Nothing is in the system log for this application, which is confirmed running.

Are the event logs saved somewhere?

Is setting a launchctl log level necessary for this?

1

To bring the contents of Mateusz's comment here in an answer. Credit to Camelot for the steps.

The AppleScript log statement does not write to the StandardOutPath. Writing to a log file takes 3 steps. The second step may take 2 forms depending of wether you want to save previously written data.

-- Open the log file
set logFile to (open for access POSIX file "/var/tmp/myScript.log" with write permission)
-- Write some data to it (clearing the existing contents)
write "some data" & return to logFile
-- Or, write by appending, some data to the end of existing data
write "some data" & return to logFile starting at eof
-- Close the file
close access logFile

It may help to rewrite the 1st step as 2 statements:

set logFilePath to "/var/tmp/myScript.log"
set logFile to (open for access POSIX file logFilePath with write permission)

I am still searching for an answer regarding the log statements and event log. At this point, I think they go into deep space.

0

Use log to display progress during script execution. It does not write output to any file. https://developer.apple.com/library/mac/documentation/AppleScript/Conceptual/AppleScriptLangGuide/reference/ASLR_cmds.html#//apple_ref/doc/uid/TP40000983-CH216-SW49

You must log in to answer this question.

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