免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1934 | 回复: 0
打印 上一主题 下一主题

lighttpd的access log [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-12-22 08:54 |只看该作者 |倒序浏览

这两天,产品那边有个需求

牵涉到lighttpd的access log

(需要在access log里加上refer信息,同时还有些特定的url不要记到access log里)

于是哈哈就翻了翻lighttpd的文档(关于access log的)

顺便贴到这里:

 

Accesslog Module: mod_accesslog
Author: Jan Kneschke
Date: 2004-11-03
Revision: 1.2

Abstract

The accesslog module …

Description

CLF like by default, flexible like apache

Options accesslog.use-syslog

send the accesslog to syslog

Default: disabled

accesslog.filename

name of the file where the accesslog should be written too if syslog is not used.

if the name starts with a ‘|’ the rest of the name is taken as the name of a process which will be spawn and will get the output

e.g.:

accesslog.filename = "/var/log/lighttpd.log" $HTTP["host"] == "mail.example.org" { accesslog.filename = "|/usr/bin/cronolog" }

Default: disabled

accesslog.format

the format of the logfile

Option Description
%% a percent sign
%h name or address of remote-host
%l ident name (not supported)
%u authenticated user
%t timestamp for the request-start
%r request-line
%s status code
%b bytes sent for the body
%i HTTP-header field
%a remote address
%A local address
%B same as %b
%C cookie field (not supported)
%D time used in ms (not supported)
%e environment (not supported)
%f phyiscal filename
%H request protocol (HTTP/1.0, …)
%m request method (GET, POST, …)
%n (not supported)
%o response header
%p server port
%P (not supported)
%q query string
%T time used in seconds
%U request URL
%v server-name
%V (not supported)
%X connection status
%I bytes incomming
%O bytes outgoing

If %s is written %>s or %<s the < and the > are ignored. They are support for compat with apache.

%i and %o expect the name of the field which should be written in curly brackets.

e.g.:

accesslog.format = "%h %l %u %t \"%r\" %b %>s \"%{User-Agent}i\" \"%{Referer}i\""

Default: CLF compatible output

Response Header

The accesslog module provides a special way to log content from the application in a accesslog file. It can be used to log the session id into a logfile.

If you want to log it into the accesslog just specify the field-name within a %{…}o like

accesslog.format = "%h %l %u %t \"%r\" %b %>s \"%{User-Agent}i\" \"%{Referer}i\" \"%{X-LIGHTTPD-SID}o\""

The prefix X-LIGHTTPD- is special as every response header starting with this prefix is assumed to be special for lighttpd and won’t be sent out to the client.

An example the use this functionality is provided below:

<?php session_start(); header("X-LIGHTTPD-SID: ".session_id()); ?>  

最后我加的配置文件是这么几句: $HTTP["url"] !~ "/(xxxxxx.ini|xxxxx.php)$" {

        accesslog.format = "%h %l %u %t \"%r\" %b %>s \"%{Referer}i\""

        accesslog.filename          = "/www/logs/access_log"

}

您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP