如何在 apache 日志的文件名中包含服务器名称?

Moh*_*ati 6 linux apache logging filenames

我想配置 apache,以便从 apache include 生成的访问日志和错误日志命名如下:

<server-name>_access_<timestamp>
<server-name>_error_<timestamp>
Run Code Online (Sandbox Code Playgroud)

我使用旋转日志计算出了时间戳部分:

CustomLog logs/access_log combined
CustomLog "|bin/rotatelogs -l /var/logs/access_%Y-%m-%d 86400" common
Run Code Online (Sandbox Code Playgroud)

我无法弄清楚的部分是如何在文件名中包含服务器名称。我正在 Linux 机器上配置 Apache。

问候,莫汉

Joh*_*ter -1

查看mod_log_config 文档;i看起来你想要%v或者%V

%...v    The canonical ServerName of the server serving the request.
%...V    The server name according to the UseCanonicalName setting.
Run Code Online (Sandbox Code Playgroud)