Symfony 日志到 Docker 容器内的 stdout
我正在为Symfony应用程序构建一个docker映像。在此图中,我想将 Symfony 日志流式传输到 stdout。因此,类似于nginx日志的配置方式,我将这行添加到我的Dockerfile中:
ln -sf /dev/stdout /var/www/project/app/logs/prod.log
在容器内部,我可以看到这个:
$ 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 -> /dev/stdout
但是,该应用程序会引发以下错误:
PHP 致命错误:无法打开流:无法打开流或文件“/var/www/project/app/logs/prod.log”的未捕获异常“UnexpectedValueException”:无法打开流:在 /var/www/project/app/cache/prod/classes 中没有此类文件或目录.php:5808
堆栈跟踪:
#0 /var/www/project/app/cache/prod/classes.php(5746): Monolog\Handler\StreamHandler->write(Array)
#1 /var/www/project/app/cache/prod/classes.php(5917): Monolog\Handler\AbstractProcessingHandler->handle(Array)
#2 /var/www/project/app/cache/prod/classes.php(6207): Monolog\Handler\FingersCrossedHandler->handle(Array)
#3 /var/www/project/app/cache/prod/classes.php(6276): Monolog\Logger->addRecord(500, 'Fatal Error: Un...', Array)
#4 /var/www/project/app/cache/prod/classes.php(1978): Monolog\Logger->log('critical', 'Fatal Error: Un...', Array)
#5 /var/www/project/app/cache/prod/classes.php(2034): Symfony\Component\Debug\ErrorHandler->handleException(Object(Symfony\Component\Debug\Exception\FatalErrorException), Array)
#6 [internal function]: Symfony\Component\Debug\E in /var/www/project/app/cache/prod/classes.php第5808行
有什么建议吗?