apache - 有没有办法在 apache 日志中获取内容长度(响应 header )?

标签 apache authentication http-headers

我希望 Apache 显示响应 header 长度(此处为 90)。 相反,它显示了一些也依赖于客户端的“奇怪”值。

尾部/var/log/apache2/access.log

xx.xx.xx.xx - - [16/Oct/2021:11:07:44 +0000] "POST /api/user HTTP/1.1" 200 796 "https://yy/login/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36 OPR/79.0.4143.72"

检查元素

HTTP/1.1 200 OK
Date: Sat, 16 Oct 2021 11:07:44 GMT
Server: Apache/2.4.41 (Ubuntu)
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate
Pragma: no-cache
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 90
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/html; charset=UTF-8

最佳答案

找到解决方案:

/etc/apache2/apache2.conf 中,LogFormat 指令必须更改如下:%b 而不是 %O。

现在 access.log 按预期报告 90。

这也在这里讨论(评论者 杰夫·帕基特):https://askubuntu.com/questions/264042/what-is-the-default-apache2-log-format-and-where-is-defined-such-default看起来这是 Ubuntu 特有的。

关于apache - 有没有办法在 apache 日志中获取内容长度(响应 header )?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69594264/

相关文章:

javascript - Angular 4 HttpClient 看不到 header

apache - 在 WebFlow 中强制使用 https

apache - WAMP 服务器端包括不适用于 .shtml 文件

PHP 仅在 Apache 中不呈现单个别名

php - 如何使用 Laravel 5 检查用户是否已确认

java - servlet 身份验证和对凭据的进一步引用

java - 为 twitch 聊天创建一个机器人。获取连接错误

http - HTTP Basic Auth 中的 Base 64 编码

apache - 使用htaccess更改文档根目录

ASP.NET 发布 Application_Error 事件