我在哪里可以找到错误日志文件?

时间:2021-11-24 05:23:12

Where can I find error log files? I need to check them for solving an internal server error shown after installing suPHP.

我在哪里可以找到错误日志文件?我需要检查它们以解决安装suPHP后显示的内部服务器错误。

6 个解决方案

#1


16  

You can use "lsof" to find open logfiles on your system. lsof just gives you a list of all open files.

您可以使用“lsof”在系统上查找打开的日志文件。 lsof只是为您提供所有打开文件的列表。

Use grep for "log" ... use grep again for "php" (if the filename contains the strings "log" and "php" like in "php_error_log" and you are root user you will find the files without knowing the configuration).

使用grep进行“log”...再次使用grep作为“php”(如果文件名包含字符串“log”和“php”,如“php_error_log”,你是root用户,你将在不知道配置的情况下找到文件) 。

        root@lnx-work:~# lsof |grep log
        ... snip
        gmain     12148 12274       user   13r      REG              252,1    32768     661814 /home/user/.local/share/gvfs-metadata/home-11ab0393.log
        gmain     12148 12274       user   21r      REG              252,1    32768     662622 /home/user/.local/share/gvfs-metadata/root-56222fe2.log
        gvfs-udis 12246             user  mem       REG              252,1    55384     790567 /lib/x86_64-linux-gnu/libsystemd-login.so.0.7.1
==> apache 12333             user  mem       REG              252,1    55384     790367 /var/log/http/php_error_log**
        ... snip 

        root@lnx-work:~# lsof |grep log |grep php 
        **apache 12333             user  mem       REG              252,1    55384     790367 /var/log/http/php_error_log**
        ... snip 

Also see this article on finding open logfiles: Find open logfiles on a linux system

另请参阅有关查找打开的日志文件的文章:在Linux系统上查找打开的日志文件

#2


11  

Works for me. How log all php errors to a log fiie?

适合我。如何将所有php错误记录到日志文件中?

Just add following line to /etc/php.ini to log errors to specified file – /var/log/php-scripts.log

只需在/etc/php.ini中添加以下行即可将错误记录到指定文件 - /var/log/php-scripts.log

vi /etc/php.ini

Modify error_log directive

修改error_log指令

error_log = /var/log/php-scripts.log

Make sure display_errors set to Off (no errors to end users)

确保display_errors设置为Off(最终用户没有错误)

display_errors = Off

Save and close the file. Restart web server:

保存并关闭文件。重启Web服务器:

/etc/init.d/httpd restart

How do I log errors to syslog or Windows Server Event Log?

如何将错误记录到syslog或Windows Server事件日志?

Modify error_log as follows :

修改error_log如下:

error_log = syslog

How see logs?

怎么看日志?

Login using ssh or download a log file /var/log/php-scripts.log using sftp:
$ sudo tail -f /var/log/php-scripts.log

#3


4  

On CentoS with cPanel installed my logs were in:

在安装了cPanel的CentoS上,我的日志位于:

/usr/local/apache/logs/error_log

在/ usr /本地/ Apache /日志/ error_log中

To watch: tail -f /usr/local/apache/logs/error_log

要观察:tail -f / usr / local / apache / logs / error_log

#4


2  

What OS you are using and which Webserver? On Linux and Apache you can find the apache error_log in /var/log/apache2/

你正在使用什么操作系统和哪个Web服务器?在Linux和Apache上,您可以在/ var / log / apache2 /中找到apache error_log

#5


1  

I am using Cent OS 6.6 with Apache and for me error log files are in

我正在使用带有Apache的Cent OS 6.6,对我来说错误日志文件也在

/usr/local/apache/log

在/ usr /本地/ Apache /日志

#6


1  

This is a preferable answer in most use cases, because it allows you to decouple execution of the software from direct knowledge of the server platform, which keeps your code much more portable. If you are doing a lot of cron/cgi, this may not help directly, but it can be set into a config at web runtime that the cron/cgi scripts pull from to keep the log location consistent in that case.

在大多数用例中,这是一个优选的答案,因为它允许您将软件的执行与服务器平台的直接知识分离,从而使代码更加便携。如果您正在执行大量的cron / cgi,这可能无法直接帮助,但可以将其设置为Web运行时的配置,cron / cgi脚本从中拉出以在该情况下保持日志位置一致。


You can get the current log file assigned natively to php on any platform at runtime by using:

您可以使用以下命令获取在运行时在任何平台上本机分配给php的当前日志文件:

ini_get('error_log');

This returns the value distributed directly to the php binary by the webserver, which is what you want in 90% of use cases (with the glaring exception being cgi). Cgi will often log to this same location as the http webserver client, but not always.

这将返回由web服务器直接分发给php二进制文件的值,这是你想要的90%的用例(明显的例外是cgi)。 Cgi通常会记录到与http webserver客户端相同的位置,但并非总是如此。

You will also want to check that it is writeable before committing anything to it to avoid errors. The conf file that defines it's location (typically either apache.conf globally or vhosts.conf on a per-domain basis), but the conf does not ensure that file permissions allow write access at runtime.

在提交任何内容之前,您还需要检查它是否可写,以避免错误。定义它的位置的conf文件(通常是基于每个域的apache.conf或vhosts.conf),但conf不确保文件权限允许在运行时进行写访问。

#1


16  

You can use "lsof" to find open logfiles on your system. lsof just gives you a list of all open files.

您可以使用“lsof”在系统上查找打开的日志文件。 lsof只是为您提供所有打开文件的列表。

Use grep for "log" ... use grep again for "php" (if the filename contains the strings "log" and "php" like in "php_error_log" and you are root user you will find the files without knowing the configuration).

使用grep进行“log”...再次使用grep作为“php”(如果文件名包含字符串“log”和“php”,如“php_error_log”,你是root用户,你将在不知道配置的情况下找到文件) 。

        root@lnx-work:~# lsof |grep log
        ... snip
        gmain     12148 12274       user   13r      REG              252,1    32768     661814 /home/user/.local/share/gvfs-metadata/home-11ab0393.log
        gmain     12148 12274       user   21r      REG              252,1    32768     662622 /home/user/.local/share/gvfs-metadata/root-56222fe2.log
        gvfs-udis 12246             user  mem       REG              252,1    55384     790567 /lib/x86_64-linux-gnu/libsystemd-login.so.0.7.1
==> apache 12333             user  mem       REG              252,1    55384     790367 /var/log/http/php_error_log**
        ... snip 

        root@lnx-work:~# lsof |grep log |grep php 
        **apache 12333             user  mem       REG              252,1    55384     790367 /var/log/http/php_error_log**
        ... snip 

Also see this article on finding open logfiles: Find open logfiles on a linux system

另请参阅有关查找打开的日志文件的文章:在Linux系统上查找打开的日志文件

#2


11  

Works for me. How log all php errors to a log fiie?

适合我。如何将所有php错误记录到日志文件中?

Just add following line to /etc/php.ini to log errors to specified file – /var/log/php-scripts.log

只需在/etc/php.ini中添加以下行即可将错误记录到指定文件 - /var/log/php-scripts.log

vi /etc/php.ini

Modify error_log directive

修改error_log指令

error_log = /var/log/php-scripts.log

Make sure display_errors set to Off (no errors to end users)

确保display_errors设置为Off(最终用户没有错误)

display_errors = Off

Save and close the file. Restart web server:

保存并关闭文件。重启Web服务器:

/etc/init.d/httpd restart

How do I log errors to syslog or Windows Server Event Log?

如何将错误记录到syslog或Windows Server事件日志?

Modify error_log as follows :

修改error_log如下:

error_log = syslog

How see logs?

怎么看日志?

Login using ssh or download a log file /var/log/php-scripts.log using sftp:
$ sudo tail -f /var/log/php-scripts.log

#3


4  

On CentoS with cPanel installed my logs were in:

在安装了cPanel的CentoS上,我的日志位于:

/usr/local/apache/logs/error_log

在/ usr /本地/ Apache /日志/ error_log中

To watch: tail -f /usr/local/apache/logs/error_log

要观察:tail -f / usr / local / apache / logs / error_log

#4


2  

What OS you are using and which Webserver? On Linux and Apache you can find the apache error_log in /var/log/apache2/

你正在使用什么操作系统和哪个Web服务器?在Linux和Apache上,您可以在/ var / log / apache2 /中找到apache error_log

#5


1  

I am using Cent OS 6.6 with Apache and for me error log files are in

我正在使用带有Apache的Cent OS 6.6,对我来说错误日志文件也在

/usr/local/apache/log

在/ usr /本地/ Apache /日志

#6


1  

This is a preferable answer in most use cases, because it allows you to decouple execution of the software from direct knowledge of the server platform, which keeps your code much more portable. If you are doing a lot of cron/cgi, this may not help directly, but it can be set into a config at web runtime that the cron/cgi scripts pull from to keep the log location consistent in that case.

在大多数用例中,这是一个优选的答案,因为它允许您将软件的执行与服务器平台的直接知识分离,从而使代码更加便携。如果您正在执行大量的cron / cgi,这可能无法直接帮助,但可以将其设置为Web运行时的配置,cron / cgi脚本从中拉出以在该情况下保持日志位置一致。


You can get the current log file assigned natively to php on any platform at runtime by using:

您可以使用以下命令获取在运行时在任何平台上本机分配给php的当前日志文件:

ini_get('error_log');

This returns the value distributed directly to the php binary by the webserver, which is what you want in 90% of use cases (with the glaring exception being cgi). Cgi will often log to this same location as the http webserver client, but not always.

这将返回由web服务器直接分发给php二进制文件的值,这是你想要的90%的用例(明显的例外是cgi)。 Cgi通常会记录到与http webserver客户端相同的位置,但并非总是如此。

You will also want to check that it is writeable before committing anything to it to avoid errors. The conf file that defines it's location (typically either apache.conf globally or vhosts.conf on a per-domain basis), but the conf does not ensure that file permissions allow write access at runtime.

在提交任何内容之前,您还需要检查它是否可写,以避免错误。定义它的位置的conf文件(通常是基于每个域的apache.conf或vhosts.conf),但conf不确保文件权限允许在运行时进行写访问。