- if (!openlog(self::IDENT, $this->logOpts, $this->logFacility)) {
- throw new InternalServerErrorException('Can\'t open syslog for ident "' . $this->channel . '" and facility "' . $this->logFacility . '""');
+ set_error_handler([$this, 'customErrorHandler']);
+ $opened = openlog(self::IDENT, $this->logOpts, $this->logFacility);
+ restore_error_handler();
+
+ if (!$opened) {
+ throw new \UnexpectedValueException(sprintf('Can\'t open syslog for ident "%s" and facility "%s": ' . $this->errorMessage, $this->channel, $this->logFacility));