如何访问Heroku上的CakePHP日志文件? [英] How can I access CakePHP log files on Heroku?

查看:145
本文介绍了如何访问Heroku上的CakePHP日志文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经部署了一个CakePHP应用程序到Heroku。 CakePHP将其日志写入 APP_ROOT / app / tmp / logs / error.log APP_ROOT / app / tmp / logs / debug.log 默认情况下,但由于没有办法获取一个shell到运行的Heroku网络动态,我看不到这些文件的内容。

I've deployed a CakePHP application to Heroku. CakePHP writes its logs in APP_ROOT/app/tmp/logs/error.log and APP_ROOT/app/tmp/logs/debug.log by default but since there's no way to get a shell to a running Heroku web dyno, I can't see the content of those files.

理解它, heroku logs 命令返回已转储到 STDERR STDOUT 。如果我是对的,有没有办法强迫CakePHP将其日志发送到 STDOUT

As I understand it, the heroku logs command returns everything which has been dumped to STDERR and STDOUT. If I'm right about that, is there a way to force CakePHP to send its logs to STDOUT?

Heroku PHP Buildpack 将Apache和PHP日志文件作为后台进程的一部分dyno设置。见下文。

The Heroku PHP Buildpack tails the Apache and PHP log files as a background process as part of the dyno setup. See below.

cat >>boot.sh <<EOF
for var in \`env|cut -f1 -d=\`; do
  echo "PassEnv \$var" >> /app/apache/conf/httpd.conf;
done
touch /app/apache/logs/error_log
touch /app/apache/logs/access_log
tail -F /app/apache/logs/error_log &
tail -F /app/apache/logs/access_log &
export LD_LIBRARY_PATH=/app/php/ext
export PHP_INI_SCAN_DIR=/app/www
echo "Launching apache"
exec /app/apache/bin/httpd -DNO_DETACH
EOF



在这个构建包的一个分支中,我添加了自己的行在适当的位置,然后将我的应用程序配置为使用我的自定义构建包。

In a fork of that build pack, I added in my own lines in the appropriate positions, then configured my app to use my custom build pack.

touch /app/www/tmp/logs/error.log
tail -F /app/www/app/tmp/logs/error.log &

但这没有效果。事实上,搁置CakePHP细节,我没有看到任何PHP或Apache日志内容在 heroku日志

But this didn't work. In fact, setting aside CakePHP specifics, I don't see any PHP or Apache log contents in the heroku logs either.

推荐答案

从Heroku文档: https:/ /devcenter.heroku.com/articles/php-logging#cakephp

From the Heroku documentation: https://devcenter.heroku.com/articles/php-logging#cakephp

在您的应用程序配置中,指示CakePHP为您的记录器设置使用ConsoleLog引擎:

In your application configuration, instruct CakePHP to use the ConsoleLog engine for your logger setups:

CakeLog::config('default', array(
    'engine' => 'ConsoleLog',
));

然后可以使用常规日志记录方法。

You can then use the regular logging methods.

CakeLog::warning("Hello, this is a test message!");

有关详细信息,请参阅CakePHP手册的日志记录部分。

Refer to the Logging section of the CakePHP manual for more information.

这篇关于如何访问Heroku上的CakePHP日志文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆