Apache 使用 TransferLog 填充错误日志

Apache 使用 TransferLog 填充错误日志

我使用的是 Apache 2.4 和几个虚拟主机。顺便说一下,这是在 Windows 上。在每个虚拟主机中,我都有以下日志文​​件配置:

CustomLog "|bin/rotatelogs.exe -l ${SRVROOT}/logs/dev.ssl_request.%Y.%m.%d.log 86400" \
      "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b" env=HTTPS

ErrorLog "|bin/rotatelogs.exe -l ${SRVROOT}/logs/dev.error.%Y.%m.%d.log 86400"
TransferLog "|bin/rotatelogs.exe -l ${SRVROOT}/logs/dev.access.%Y.%m.%d.log 86400"

那将是开发虚拟主机。其他(test/ua/等)除了ServerName不同,日志命名为{environment}.error等,其他基本相同。

现在,当我启动 Apache 时,错误日志文件会一遍又一遍地重复相同的消息。该消息是:

Incorrect number of arguments
Usage: C:\Program Files\Apache Software Foundation\Apache24\bin\rotatelogs.exe [-v] [-l] [-L linkname] [-p prog] [-f] [-t] [-e] [-n number] <logfile> {<rotation time in seconds>|<rotation size>(B|K|M|G)} [offset minutes from UTC]

Add this:

TransferLog "|C:\Program Files\Apache Software Foundation\Apache24\bin\rotatelogs.exe /some/where 86400"

or 

TransferLog "|C:\Program Files\Apache Software Foundation\Apache24\bin\rotatelogs.exe /some/where 5M"

to httpd.conf. By default, the generated name will be
<logfile>.nnnn where nnnn is the system time at which the log
nominally starts (N.B. if using a rotation time, the time will
always be a multiple of the rotation time, so you can synchronize
cron scripts with it). If <logfile> contains strftime conversion
specifications, those will be used instead. At the end of each
rotation time or when the file size is reached a new log is
started.

Options:
  -v       Verbose operation. Messages are written to stderr.
  -l       Base rotation on local time instead of UTC.
  -L path  Create hard link from current log to specified path.
  -p prog  Run specified program after opening a new log file. See below.
  -f       Force opening of log on program start.
  -t       Truncate logfile instead of rotating, tail friendly.
  -e       Echo log to stdout for further processing.

The program is invoked as "[prog] <curfile> [<prevfile>]"
where <curfile> is the filename of the newly opened logfile, and
<prevfile>, if given, is the filename of the previously used logfile.

我不知道为什么会发生这种情况。此外,在将 Apache 放到我们的 Web 服务器上之前,我在笔记本电脑上本地运行了完全相同的设置,并且日志记录工作正常,没有错误消息。

有任何想法吗?

谢谢。

更新

根据 Jeff Snider 的建议,我更进一步,删除了“${SRVROOT}”,并将所有内容更改为“logs/dev.error....”。我在 Apache 文档中读到,如果您不指定 /,则它无论如何都会默认为 SRVROOT。

在我这样做之后,我开始看到一些日志弹出。并且,错误日志很稳定。但是,几分钟后,它又开始发生。

我甚至在每个环境中禁用了所有“TransferLog”,只保留 CustomLog 和 ErrorLog。结果还是一样。

我的当前配置现在是:

CustomLog "|bin/rotatelogs.exe -l logs/dev.ssl_request.%Y.%m.%d.log\ 86400" \
      "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b" env=HTTPS

ErrorLog "|bin/rotatelogs.exe -l logs/dev.error.%Y.%m.%d.log 86400"

答案1

${SRVROOT}尝试在命令行中加上引号。我怀疑它有空格,这些空格可能会使它看起来像几个单独的参数而造成混淆。

相关内容