apache - 从 Apache 日志中排除用户代理

标签 apache ubuntu logging referer

我正在寻找您可以拥有的解决方案:)
我尝试排除 用户代理 到 apache 日志,但保留 推荐人 .
这是我尝试过的

LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\"" common
CustomLog ${APACHE_LOG_DIR}/xxx_access.log common

但是当我这样做时,Referer也被排除在外...

我试图替换 common通过 combined但还是一样...

这就是我想要做的:
 IP - [date] "GET / HTTP/1.1" 200 9062 "Referer"

有任何想法吗?
这是不可能的 ... ?
combined同时显示Referer和User Agent
我做错了吗?

最佳答案

进入您的/etc/apache2/apache.conf (或 apache2.conf )。
在底部你应该看到

LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent

所以尝试更换
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined

经过
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\"" combined

重新启动 Apache,它应该可以工作。

关于apache - 从 Apache 日志中排除用户代理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25672061/

相关文章:

php - 无法正常启动XAMPP

ruby - 使用 rbenv 不适用于 sudo?

java - 在 CloudFoundry 记录器日志中保留原始控制台颜色

python - FastAPI 中的中间件,用于为每个请求生成 UUID 并发送到日志

python - 如何抑制错误消息 : "Error in ` ./hubbard.exc' : corrupted size vs. prev_size"?

java - 如何在struts应用程序中将log4j的日志文件保留在WEB-INF下

apache - 如何在使用 MAMP 运行的 Apache 服务器中包含 SSL 证书文件

php - 函数 session_start() 的问题(运行缓​​慢)

php - 在一台 Apache 服务器上的单独虚拟主机中运行 Apache mod_php 和 mod_fastcgi

linux - 如何在 Ubuntu Linux 上安装共享库?