MacOS – How to add a timestamp in log files on launchd

launchdlogsmacos

In launchd, you can change the path of the log files using StandardOutPath and StandardErrorPath in .plist file, but when I used it to output a log returned by the process, the resultant log files didn't add a timestamp and hence I cannot tell when each line is written nor when the process is run to begin with.

So is it feasible to add the timestamp information to the log files? The minimum requirement is month, day, hour, minute, and second.

Best Answer

The keys you mention don't redirect log files, they redirect the standard output/error streams. It is the responsibility of the program writing to those streams to add timestamp information.