我需要一些帮助来自定义我在 Lighttpd 1.4.28 上的访问日志。到目前为止,我已经能够修改配置以strftime(3)格式显示日期。默认日期格式太长了。以下是来自的相关行/etc/lighttpd/lighttpd.conf
accesslog.format = "%s [%{%d%b-%H:%M}t] %h %b %U * %{From}i|%{Via}i|%{Referer}i *
accesslog.filename = "/web/lighttpd_access.log"
这是我的 access.log 条目:
404 [24Aug-16:55] 98.68.178.112 345 /phpMyAdmin/scripts/setup.php * -|-|- * "Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.215 Safari/535.1"
自定义日期并不难,但我在尝试显示请求 URL 的同时使用自定义 404 页面时遇到了问题。我刚刚添加
server.error-handler-404 = "/error.html"
到lighttpd.conf
文件,lighttpd_access.log
现在包含 redirected /error.html
,而不是生成错误的请求的完整 url。
200 [24Aug-16:06] 98.68.178.112 1 /error.html * -|-|- * "Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.215 Safari/535.1"
我也尝试过添加%{Request_URI}i
,但日志条目是-
空白的。任何人都知道尝试将原始请求 URL 与自定义 404 页面结合使用时使用的正确语法吗?