Apache 错误日志:仅记录部分服务器


Apache Error log: Log only for part of server

我在VPS服务器上运行Debian,并且在同一台服务器上同时拥有开发和生产代码以及数据库。

是否可以让服务器仅记录服务器开发部分的错误,而不是生产部分的错误。现在,生产端记录了如此多的错误,这使得很难找到开发错误。

虽然这确实属于 serverfault.com:

您绝对应该始终记录所有错误。

例如,如果您在服务器上托管 2 个域,则可以为要存储日志的每个虚拟主机指定 example.com 和 test.example.com。

在 apache 上,您的虚拟主机可能如下所示:

<VirtualHost xxx.xxx.xxx.xxx:80>
    // some configuration stuff
    ServerName     example.com
    // some more configuration stuff
    CustomLog      /var/log/httpd/example.com-access_log combined
    ErrorLog       /var/log/httpd/example.com-error_log
</VirtualHost>
<VirtualHost xxx.xxx.xxx.xxx:80>
    // some configuration stuff
    ServerName     test.example.com
    // some more configuration stuff
    CustomLog      /var/log/httpd/test.example.com-access_log combined
    ErrorLog       /var/log/httpd/test.example.com-error_log
</VirtualHost>

因此,您可以轻松区分test.example.comexample.com的日志信息。