php 实时查看apache错误日志

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16613340/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 11:26:37  来源:igfitidea点击:

View apache error log in real time

phpapache

提问by user350325

I am building a PHP app using mod_php in apache. However during the course of development I will have syntax errors in the code (of course).

我正在使用 apache 中的 mod_php 构建一个 PHP 应用程序。但是在开发过程中我会在代码中出现语法错误(当然)。

When I load the page with errors on I get a 500 page, if I want to view the actual error message I have to go into /var/log and cat the actual error log. This is quite annoying to do in development all the time.

当我加载有错误的页面时,我得到一个 500 页,如果我想查看实际的错误消息,我必须进入 /var/log 并查看实际的错误日志。这在开发过程中一直很烦人。

I know that one can have errors show up on the web page, but this is not always convenient either when working with JSON etc and it messes up the page.

我知道网页上可能会显示错误,但这在使用 JSON 等时并不总是很方便,并且会弄乱页面。

I know that with most python framework for example , error messages are just printed to stdout when the server application is run, however in this case since I am just attaching PHP to the apache service background process I don't see how that would be possible.

我知道,例如,对于大多数 python 框架,当服务器应用程序运行时,错误消息只是打印到标准输出,但是在这种情况下,因为我只是将 PHP 附加到 apache 服务后台进程,我不知道这是怎么可能的.

Is there some way to view the error logs in real time in a window with apache?

有什么办法可以用apache在窗口中实时查看错误日志吗?

回答by bobwienholt

tail -f /var/log/apache/error.log

回答by Ivan Ferrer

In real time use:

实时使用:

sudo watch tail /var/log/apache2/error.log