PHP 的错误日志位于 XAMPP 中的什么位置?
我一直在使用 Windows 版 XAMPP。
PHP 的错误日志位于 XAMPP 中的什么位置?
I've been using XAMPP for Windows.
Where does PHP's error log reside in XAMPP?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(14)
\xampp\apache\logs\error.log
,其中xampp
是您的安装文件夹。如果您没有更改 PHP 中的
error_log
设置(使用phpinfo()
检查),它将被记录到 Apache 日志中。\xampp\apache\logs\error.log
, wherexampp
is your installation folder.If you haven't changed the
error_log
setting in PHP (check withphpinfo()
), it will be logged to the Apache log.我在以下位置找到了它:
\xampp\php\logs\php_error_log
I found it in:
\xampp\php\logs\php_error_log
您还可以打开 XAMPP 控制面板,然后单击按钮日志:
You can also open the XAMPP control panel and click on the button Logs:
无论出于何种原因,
\xampp\php\logs
对我来说根本不存在。我只需在
\xampp\php\
中创建一个名为logs
的文件夹,然后创建并写入php_error_log
文件。\xampp\php\logs
did not exist at all for me - for whatever reason.I simply had to create a folder in
\xampp\php\
calledlogs
and then thephp_error_log
file was created and written to.对于 Mac 用户,XAMPP 版本 1.7.3:
For Mac users, XAMPP version 1.7.3:
对于在 Ubuntu 的 XAMPP 中搜索 PHP 日志文件的人来说,它是:
很可能它会很大(我的大约 350 MB),并且当我打开该文件时,它会减慢我的文本编辑器的速度。如果您不关心以前的所有日志,只需转到终端,然后一一写入这三行即可轻松清空文件:
现在,新的日志将可以轻松快速地打开。尖括号清空文件(仅适用于
bash
,不适用于 zsh)。For anyone searching for the PHP log file in XAMPP for Ubuntu, it is:
Most probably it will be having a big size (mine was about 350 MBs) and it slowed down my text editor when I opened the file. If you do not care about all the previous logs you can empty the file easily by simply going to the terminal and then writing these three lines one by one:
And newer logs will be easy and fast to open now. The angle bracket empties the file (Works with
bash
only, doesn't work on zsh).查看配置文件并搜索 error_log 设置。或者使用 phpinfo() 来查找此设置。
Look in your configuration file and search for the error_log setting. Or use phpinfo() to find this setting.
您可以简单地从 phpMyAdmin 检查日志路径。
运行这个:
现在点击 PHPInfo(右上角),或者您可以简单地在浏览器中打开此 URL:
现在搜索“error_log”(不带引号)。您将获得日志路径。
You can simply check your log path from phpMyAdmin.
Run this:
Now click PHPInfo (top right corner) or you can simply open this URL in your browser:
Now search for "error_log"(without quotes). You will get the log path.
默认情况下,XAMPP PHP 日志文件路径位于 /xampp_installation_folder/php/logs/php_error_log 中,但我注意到有时它不会自动生成。也许是 Windows 帐户写权限问题?我不确定,但我手动创建了日志文件夹和 php_error_log 文件,然后 PHP 日志最终记录在其中。
By default, the XAMPP PHP log file path is in /xampp_installation_folder/php/logs/php_error_log, but I noticed that sometimes it would not be generated automatically. Maybe it could be a Windows account write permission problem? I am not sure, but I created the logs folder and php_error_log file manually and then PHP logs were logged in it finally.
在我刚刚安装的当前版本 (8.0.11) 中,安装程序“忘记”创建文件夹
C:\xamppp\php\logs
,这可能是设计使然,但这就是 ApacheFriends 为您准备的In the current version I've just installed (8.0.11) the installer "forgets" to create the folder
C:\xamppp\php\logs
, perhaps by design but that is ApacheFriends for you????. After creating the folder and restarting Apache the folder will be populated with aphp_error_log
file. No, not a php_error.log but php_error_log, becouse they are your friends.Follow
Terminal
To keep seeing the last entry (much like *nix sh
tail -f
) use the following command:This will keep reading the file and display the last entries. Quite handy if you are debugging.
Code
You might be using vscode so why not have the errors right at you finger tips. Create a file
.vscode\tasks.json
and allow it to run on start. Make sure you work on a folder, not single files, but you were doing that already, weren't you?
\xampp\apache\logs\error.log 是 PHP 中错误日志的默认位置。
\xampp\apache\logs\error.log is the default location of error logs in PHP.
正如前面的答案所说,您可以在Windows中找到PHP错误日志。在
C:\xampp\apache\logs\error.log
中。您可以通过tail -f .\error.log
轻松显示最后的日志。As said in previous answers, you can find the PHP error log in Windows. In
C:\xampp\apache\logs\error.log
. You can easily display the last logs bytail -f .\error.log
.对于 Mac 用户,可以在以下位置找到:
/Applications/XAMPP/xamppfiles/logs/php_error_log
For Mac users, it can be found in:
/Applications/XAMPP/xamppfiles/logs/php_error_log
对于我的问题,我必须将日志清零:
sudo bash -c ' > /Applications/XAMPP/xamppfiles/logs/php_error_log '
For my issue, I had to zero out the log:
sudo bash -c ' > /Applications/XAMPP/xamppfiles/logs/php_error_log '