Re: [squid-users] http_accel mode logs

From: Henrik Nordstrom <hno@dont-contact.us>
Date: Tue, 16 Oct 2001 22:39:52 +0200

There is an earlier patch referenced from devel.squid-cache.org. See
"Extended common log format" in the secion "Other Squid works not (yet)
hosted here".

Not sure which of the two slightly different approaches I prefer.
Neither are perfect, both gets the job done.

Added a reference to your version to keep track of it. The logging
formats is something which needs to be addressed one way or another.

Regards
Henrik Nordström
Squid Hacker

AJ Lemke wrote:
>
> After searching through the mailing list numerous times I came upon this:
> *************************************************************************
>
> After searching in vain for a patch to have squid log referer, useragent
> and cookie info in the httpd emulated log, I tried to hack one in the
> source myself. And it is looking good! I'ts a real quick and dirty
> (emphasis on dirty) hack but so far it's been working great for me.
> There are no fancy config options just make sure you enable the
>
> emulate_httpd_log on
>
> line in squid.conf. You then will get a squid access-log like this
> apache-style format:
> LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"
> \"%v\" \"%{Cookie}i\""
>
> plus the squid specific entry at the end of each line.
>
> The patch is intend for use only in httpd_accel mode, to log the extra
> (often used) info you get from apache but is missing from squid. The
> patch is made against a recent snapshot, but works with the latest
> 2.3.STABLE4 too. I don't have much c programming experience so I might
> have introduced some mem-leaks or something :) But then again squid is
> quite a space-hog, so you probably wouldn't notice it anyway :).
>
> If you're gona use this patch, it's entirely at you own risk, but like I
> said it works great for us. Since I saw a lot of people on this list
> were searching for something like this, but all the links and pointers
> to hints mentioned were dead, I thought to be nice and share this litte
> hack. Let me know if it works for you.
>
> alex.
>
> combined_log-patch:
> ----------------------- cut here -----------------------
> *** squid-2.3-200010032300/src/access_log.c Tue Mar 14 07:48:22 2000
> --- squid-2.3-combined_log/src/access_log.c Thu Oct 12 23:11:45 2000
> ***************
> *** 217,223 ****
> client = fqdncache_gethostbyaddr(al->cache.caddr, 0);
> if (client == NULL)
> client = inet_ntoa(al->cache.caddr);
> ! memBufPrintf(mb, "%s %s - [%s] \"%s %s HTTP/%.1f\" %d %d %s:%s",
> client,
> al->cache.ident,
> mkhttpdlogtime(&squid_curtime),
> --- 217,223 ----
> client = fqdncache_gethostbyaddr(al->cache.caddr, 0);
> if (client == NULL)
> client = inet_ntoa(al->cache.caddr);
> ! memBufPrintf(mb, "%s %s - [%s] \"%s %s HTTP/%.1f\" %d %d \"%s\"
> \"%s\" \"%s\" %s:%s",
> client,
> al->cache.ident,
> mkhttpdlogtime(&squid_curtime),
> ***************
> *** 226,231 ****
> --- 226,234 ----
> al->http.version,
> al->http.code,
> al->cache.size,
> + al->http.referer,
> + al->http.agent,
> + al->http.cookie,
> log_tags[al->cache.code],
> hier_strings[al->hier.code]);
> }
> diff -crN squid-2.3-200010032300/src/client_side.c
> squid-2.3-combined_log/src/client_side.c
> *** squid-2.3-200010032300/src/client_side.c Thu Sep 7 06:06:59 2000
> --- squid-2.3-combined_log/src/client_side.c Thu Oct 12 23:14:01 2000
> ***************
> *** 643,648 ****
> --- 643,652 ----
> ConnStateData *conn = http->conn;
> StoreEntry *e;
> request_t *request = http->request;
> + const HttpHeader *req_hdr = &request->header;
> + const char *agent;
> + const char *referer;
> + const char *cookie;
> MemObject *mem = NULL;
> debug(33, 3) ("httpRequestFree: %s\n", storeUrl(http->entry));
> if (!clientCheckTransferDone(http)) {
> ***************
> *** 658,663 ****
> --- 662,670 ----
> if (http->entry)
> mem = http->entry->mem_obj;
> if (http->out.size || http->log_type) {
> + agent = httpHeaderGetStr(req_hdr, HDR_USER_AGENT);
> + referer = httpHeaderGetStr(req_hdr, HDR_REFERER);
> + cookie = httpHeaderGetStr(req_hdr, HDR_COOKIE);
> http->al.icp.opcode = ICP_INVALID;
> http->al.url = http->log_uri;
> debug(33, 9) ("httpRequestFree: al.url='%s'\n", http->al.url);
> ***************
> *** 669,674 ****
> --- 676,684 ----
> http->al.cache.size = http->out.size;
> http->al.cache.code = http->log_type;
> http->al.cache.msec = tvSubMsec(http->start, current_time);
> + http->al.http.agent = agent;
> + http->al.http.referer = referer;
> + http->al.http.cookie = cookie;
> if (request) {
> Packer p;
> MemBuf mb;
> diff -crN squid-2.3-200010032300/src/structs.h
> squid-2.3-combined_log/src/structs.h
> *** squid-2.3-200010032300/src/structs.h Thu Mar 30 00:56:57 2000
> --- squid-2.3-combined_log/src/structs.h Thu Oct 12 00:03:40 2000
> ***************
> *** 823,828 ****
> --- 823,831 ----
> int code;
> const char *content_type;
> float version;
> + const char *agent;
> + const char *referer;
> + const char *cookie;
> } http;
> struct {
> icp_opcode opcode;
> ----------------------- cut here -----------------------
> **********************************************************************
>
> Now my question is this has anyone tried this and is it effective. I am
> using the latest stable build and would like to know if this is still
> feasible with this version?
>
> AJ
Received on Tue Oct 16 2001 - 14:48:14 MDT

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 17:02:47 MST