We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

nginx's log does'nt work

It was supposed that errorlog is output to /var/log/nginx/error.log

But In fact it was not output.

my test code is below.

testController↓

    public function get()
    {
        return $this->getDI()->get("not_exist_di_module")->hoge;
    }

nginx.conf↓

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log error;
pid /run/nginx.pid;

...

and


$app->error(
  function (Exception $exception) use ($app) {
    $logger = new Logger\Adapter\Syslog(null);
    $logger->error("#######");
});

It's not work↑.


$app->error(
  function (Exception $exception) use ($app) {
        $logger = new Stream("php://stderr");
        $logger->error("This is another error");
});

It's not work↑.


$app->error(
  function (Exception $exception) use ($app) {
        $app->response->setStatusCode(500, "error of 500.")->send();
});

It's not work↑.


$app->error(
  function (Exception $exception) use ($app) {
        throw $exception;
});

It's not work↑.


//   $app->error(
//   function (Exception $exception) use ($app) {
//         throw $exception;
//   });

It's not work↑.

My environment is below.

Phalcon DevTools (3.4.0)

Environment:
  OS: Linux fc4f20c672e4 4.9.60-linuxkit-aufs #1 SMP Mon Nov 6 16:00:12 UTC 2017 x86_64
  PHP Version: 7.2.8
  PHP SAPI: cli
  PHP Bin: /usr/bin/php
  PHP Extension Dir: /usr/lib64/php/modules
  PHP Bin Dir: /usr/bin
  Loaded PHP config: /etc/php.ini
Versions:
  Phalcon DevTools Version: 3.4.0
  Phalcon Version: 3.4.1
  AdminLTE Version: 2.3.6

Please help me.

edited Sep '18

You have to distinguish between user level errors and server errors.

By default this is what you might see at nginx side:

2018/09/24 22:45:19 [error] 8243#0: *9612874 upstream prematurely closed connection while reading response header from upstream, client: 176.74.xxx.xxx, server: live2.dmn.com, request: "GET /huis_en_outdoors/huishouding/wasdrogers.html HTTP/1.1", upstream: "https://192.168.200.19:80/huis_en_outdoors/huishouding/wasdrogers.html", host: "www.dmn.nl"

More details about nginx logging:

https://docs.nginx.com/nginx/admin-guide/monitoring/logging/