How do I activate launchd logging on OS X?

Assuming you’re trying to log your process rather than launchd itself,
if you include the following lines in the launchd plist file:

<key>StandardOutPath</key>
<string>/path/to/logfile.log</string>
<key>StandardErrorPath</key>
<string>/path/to/another_logfile.log</string>

and reload the process, any logging or printing that you have internal to your script will be captured in one of those two files whenever it is run. though rotating the files appears to be up to you. as you might expect, if you use the same file in both instances, it will log both error and stdout to the same place.

See: Debugging launchd Jobs section at Creating Launch Daemons and Agents.

Leave a Comment