Error logging in MediaWiki maintenance scripts is a bit of a mess:
- Maintenance scripts call Setup.php relatively late (and even within Setup.php exception handling is set up relatively late - that's T177735: Error handling is set up too late to catch extension registration errors), so any error that's thrown within e.g. Maintenance::setup() does not get handled at all.
- Maintenance::execute() is wrapped in a try..catch that prints the error message to stderr and otherwise suppresses the error. The default systemd config sends stderr to /var/log but doesn't seem to report it in a more useful way.
- Errors thrown in other parts (e.g. Maintenance::validateParamsAndArgs()) are handled by the top-level exception handler in the usual way (sent to Logstash + written to stdout).
It would probably make more sense to always pass errors to MWExceptionHandler::logException().