Stderr error log from launchd scripts filled with non-errors

launchdlogsscript

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

<key>StandardErrorPath</key>
    <string>/script_logs/server.domain_expiration.error.log</string>

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.

Best Answer

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.

Related Question