0

While developing a web service in Symfony 4.3 I need to show logs in the terminal to check the content of some variables. For this I initialize the server with:

symfony server:start --port=8000

And the server starts

[OK] Web server listening on http://127.0.0.1:8000 (PHP FPM 7.2.19)
WARNING unable to find the application log

In my code I have a few logs like:

public function findItems(string $data): Items
{
    [$code, $result] = Curl::makeCurl($data);

    echo 'CODE';
    print_r($code);
    echo 'RESULT';
    print_r($result);

    $items = doSomething($result);

    return $items;
}

But Even if the web server terminal shows the controller receiving the call and the code failing in the line:

$items = doSomething($result);

The logs above are not showing.

Is there a way I can see the logs in the web server?

Belen
  • 673
  • 2
  • 10
  • 25
  • 1
    nothing in ./var/log/dev.log? – Manzolo Aug 23 '19 at 12:18
  • @AndreaManzi Nope – Belen Aug 23 '19 at 12:21
  • "Running the server this way makes it display the log messages in the console" from doc https://symfony.com/doc/current/setup/symfony_server.html#getting-started – Manzolo Aug 23 '19 at 12:24
  • Please post doSomething function – Manzolo Aug 23 '19 at 12:25
  • doSomething is just an example, I've edited the question, I found an interesting message after the server starts. My log route is /var/log/ not ./var/log/ could be something related with this? – Belen Aug 23 '19 at 12:31
  • 1
    Try starting server with `symfony server:start -d` and show log with `symfony server:log` – Manzolo Aug 23 '19 at 12:33
  • 1
    `echo` should output to the browser, not the server log. Try using a proper [`Logger`](https://symfony.com/doc/current/logging.html#logging-a-message). – msg Aug 23 '19 at 12:46

0 Answers0