作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我希望 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 OKDate: Sat, 16 Oct 2021 11:07:44 GMTServer: Apache/2.4.41 (Ubuntu)Expires: Thu, 19 Nov 1981 08:52:00 GMTCache-Control: no-store, no-cache, must-revalidatePragma: no-cacheVary: Accept-EncodingContent-Encoding: gzipContent-Length: 90Keep-Alive: timeout=5, max=100Connection: Keep-AliveContent-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/
我是一名优秀的程序员,十分优秀!