【问题标题】:Apache2: No Effect Of ErrorLogFormatApache2:ErrorLogFormat 没有影响
【发布时间】:2019-03-18 10:28:13
【问题描述】:

我在 /etc/apache2/apache2.conf 更改了 ErrorLogFormat,但这不会影响日志。我还将我的 ErrorLogFormat 添加到启用站点的目录中的配置文件中,但没有效果。

ErrorLogFormat "[%{%Y-%m-%d %H:%M:%S}t] [%l] [client %a] %M"

这是日志:

[Sat Oct 13 13:01:56 2018] [error] [client 123.123.123.123:41204] AH01790: user `asd' in realm `some realm' not found: /

编辑:它在更新的树莓派上运行。我测试过:停止和启动,在 apache 服务上重新启动和系统重新启动。

grep -r "ErrorLogFormat" /etc/apache2

仅显示了我在 apache.conf 中添加的所需格式以及在启用站点时添加的 conf 文件。

【问题讨论】:

  • 你重启了 Apache 吗?不优雅,句号 - 开始。
  • 感谢您的建议。我现在测试了它,但没有成功。查看我的编辑。

标签: apache http logging apache2.4


【解决方案1】:

在 Apache 2.4 (https://httpd.apache.org/docs/2.4/mod/core.html#errorlogformat) 中,您可以使用:

ErrorLogFormat "[%{cu}t] [%l] [client %a] %M"

%{cu}t: 紧凑 ISO 8601 格式的当前时间,包括微秒

在日志文件中会显示:

[2018-10-14 10:31:05.273482] [debug] [client AH00931: 在子 4296 中为 (localhost) 初始化单连接工作者

日期格式和你想要的一样,不用指定你所有的规则。


如果使用%{u}t,则日志格式变为:

[Sun Oct 14 10:30:31.944078 2018] [info] [client ::1:47376] AH00128:文件不存在:/home/mbert/tools/apache/htdocs/so/oij

这是你以前的。

【讨论】:

  • 非常感谢。那行得通。好的,现在我看到 ErrorLogFormat 的规则与 LogFormat 不同。顺便说一句,你得到了我的支持,但它不是公开的原因我是新的:)
  • @Nic3500 你能猜到为什么%a 会显示为空白吗?它应该是客户端IP地址。我 posted a question 关于那个。
猜你喜欢
  • 1970-01-01
  • 2013-11-17
  • 1970-01-01
  • 2020-09-06
  • 1970-01-01
  • 1970-01-01
  • 2021-01-30
  • 1970-01-01
  • 2020-11-10
相关资源
最近更新 更多