I've added versions of the following to each of the launchd plist files for all of the scripts I run on my server:


These are all PHP shell scripts, so I capture standard output with an output buffer and store that in an SQL database, not in a log file. But for the errors, I use this to create error logs.

The problem is that what I'm getting in my error logs is often not errors. For example, the error log for my launchd VPN script writes every incoming VPN connection to the error log.

2019-05-04 06:33:43 EDT Server 'com.apple.ppp.l2tp' starting...
2019-05-04 06:33:43 EDT Loading plugin /System/Library/Extensions/L2TP.ppp
2019-05-04 06:33:43 EDT Listening for connections...
2019-05-04 06:34:23 EDT Incoming call... Address given to client = [redacted]
2019-05-04 06:35:21 EDT    --> Client with address = [redacted] has hungup
2019-05-04 06:35:35 EDT Incoming call... Address given to client = [redacted]

That doesn't look like error output. That looks like regular old normal, no problem output. The two "calls" were me connecting and disconnecting from the VPN normally.

What is going on here? It's possible I'm not fully understanding what stderr and stdout actually are. Does this make sense to anyone?

I'll have more examples in a few hours once more scripts run, as I have intentionally flushed all these logs.


There is nothing wrong with the output you are capturing.

Convention Only

Developers are free to output anything they want to stdout and stderr. Convention suggests passing error related output to stderr but nothing enforces this choice.

In this instance the php script authors have written debug or progress information to stderr. I presume they expected stderr to be ignored, until a problem needs debugging.

See Confused about stdin, stdout and stderr? for a detailed question and answer on the subject.

  • I see. It seems like stdout, possibly with use of a flag, would be a better place for debug info than stderr. But nothing I can do about it it seems. This sure seems like the answer to my vpn launching script but one of my php shell scripts seemed to be logging in a very weird way. I'll post back here when I have more data. – l008com May 4 '19 at 11:58
  • 1
    @l008com Consider a pipeline like cmd1 | cmd2 | cmd3 > outfile. Each of those programs has a certain expected output that it's supposed to produce to pass on to the next command (or the output file); any output other than that needs to be sent to stderr instead of stdout, so it won't confuse the next program in line (or interrupt the expected output). For example, when curl or wget prints a download progress message, they send it to stderr so it can't get mixed in with the file being downloaded. – Gordon Davisson May 4 '19 at 20:33
  • It seems to me, there needs to be three output streams. One for real errors, one for general human-eyes output, and one for output that is specifically means to be fed into another program. Quick, change unix! – l008com May 4 '19 at 20:41

You must log in to answer this question.

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