Symfony logs to stdout inside Docker container
<p>I'm building a docker image for a Symfony application. In this image, I want to stream the Symfony logs to stdout. So, similar to how nginx logs are configured, I added this line to my Dockerfile:</p>

<pre><code>ln -sf /dev/stdout /var/www/project/app/logs/prod.log
</code></pre>

<p>Inside the container, I can see this:</p>

<pre><code>$ ls /var/www/project/app/logs/ -l
total 12
-rw-r--r-- 1 501 games 4473 Jul 21 08:36 dev.log
lrwxrwxrwx 1 501 games   11 Jul 21 08:35 prod.log -&gt; /dev/stdout
</code></pre>

<p>However, the app throws following error:</p>

<blockquote>
  <p>PHP Fatal error:  Uncaught exception 'UnexpectedValueException' with message 'The stream or file "/var/www/project/app/logs/prod.log" could not be opened: failed to open stream: No such file or directory' in /var/www/project/app/cache/prod/classes.php:5808<br>Stack trace:<br>#0 /var/www/project/app/cache/prod/classes.php(5746): Monolog\Handler\StreamHandler->write(Array)<br>#1 /var/www/project/app/cache/prod/classes.php(5917): Monolog\Handler\AbstractProcessingHandler->handle(Array)<br>#2 /var/www/project/app/cache/prod/classes.php(6207): Monolog\Handler\FingersCrossedHandler->handle(Array)<br>#3 /var/www/project/app/cache/prod/classes.php(6276): Monolog\Logger->addRecord(500, 'Fatal Error: Un...', Array)<br>#4 /var/www/project/app/cache/prod/classes.php(1978): Monolog\Logger->log('critical', 'Fatal Error: Un...', Array)<br>#5 /var/www/project/app/cache/prod/classes.php(2034): Symfony\Component\Debug\ErrorHandler->handleException(Object(Symfony\Component\Debug\Exception\FatalErrorException), Array)<br>#6 [internal function]: Symfony\Component\Debug\E in /var/www/project/app/cache/prod/classes.php on line 5808</p>
</blockquote>

<p>Any suggestions ? </p>