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

时间:2019-07-16 12:13:05

标签: 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.

1 个答案:

答案 0 :(得分:0)

是的,您可以使用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