在日志文件中记录 apache 的启动和停止



是否可以将启动、停止和重新启动消息记录在不同的日志文件中?

我想在 PHP 中使用特定消息的日期和时间。

[Tue Jul 16 14:00:13.378138 2019] [mpm_winnt:notice] [pid 376:tid 392] AH00455: Apache/2.4.34 (Win32) OpenSSL/1.1.0i PHP/7.2.9 configured -- resuming normal operations
[Tue Jul 16 14:02:50.737738 2019] [mpm_winnt:notice] [pid 376:tid 392] AH00422: Parent: Received shutdown signal -- Shutting down the server.

是的,您可以使用 apache 条件日志和多个访问日志来做到这一点。

多个访问日志。

LogFormat "%h %l %u %t "%r" %>s %b" common
CustomLog logs/access_log common
CustomLog logs/referer_log "%{Referer}i -> %U"
CustomLog logs/agent_log "%{User-agent}i"

条件访问日志。

# Mark requests from the loop-back interface
SetEnvIf Remote_Addr "127.0.0.1" dontlog
# Mark requests for the robots.txt file
SetEnvIf Request_URI "^/robots.txt$" dontlog
# Log what remains
CustomLog logs/access_log common env=!dontlog

参考网址 : https://httpd.apache.org/docs/2.4/logs.html

最新更新