You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Ben Laurie <be...@gonzo.ben.algroup.co.uk> on 1996/10/23 17:02:21 UTC

Re: Putting the date into the referer log.

Michael Smith wrote:
> 
> I would like to put the date into my referer logs.  It's a pretty
> easy change to make to mod_log_referer.c, and I include a patch to
> show what I've done (this is my first attempt to hack the server 
> so sorry if it breaches any guidelines).  If this is not considered
> a suitable way to implement such a feature, then any suggestions?

Use mod_log_config...

Cheers,

Ben.

> 
> Thanks
> 
> Michael Smith
> 
> 174a175,178
> >     time_t now;
> >     struct tm *date;
> >     char s[80];
> > 
> 206a211,214
> > 
> >         time(&now);
> >         date=localtime(&now);
> >         strftime(s,80,"%c",date);
> 208c216
> <         str = pstrcat(orig->pool, referer, " -> ", r->uri, "\n",
> NULL);
> ---
> >         str = pstrcat(orig->pool, s, " : ", referer, " -> ", r->uri, "\n", NULL);

-- 
Ben Laurie                  Phone: +44 (181) 994 6435
Freelance Consultant and    Fax:   +44 (181) 994 6472
Technical Director          Email: ben@algroup.co.uk
A.L. Digital Ltd,           URL: http://www.algroup.co.uk
London, England.            Apache Group member (http://www.apache.org)

Re: SetEnvIf/HeaderMatch (was Re: Putting the date into the referer log.)

Posted by Ed Korthof <ed...@organic.com>.
On Nov 4,  9:19am, Paul Sutton wrote:
> Subject: Re: Putting the date into the referer log.
>
> Ok, here is a first draft of my 'mod_setenvif'. I've called the directive
> SetEnvIf rather than HeaderMatch because it is capable of much more than
> just matching on headers (and it is functionally similar to a conditional
> SetEnv module, although it uses BrowserMatch syntax for setting env-vars,
> not SetEnv). So the example becomes
>
>   SetEnvIf User-Agent /^Mozilla/ netscape=yes
>
> There is a SetEnvIfNoCase to correspond with BrowserMatchNoCase. I'd
> prefer to make case-ness an argument, but passing more than three gets
> tricky. This module already needs an extra options argument, ITERATE3
> (patch also enclosed).

Hi y'all (my first post to this list) --

I have a request for this module, which I'd be willing to help code.  Is there
some way to extract part of the UA string?  I'd like to be able to get the
version number of the browser, and possibly other information.  (This could
certainly wait till after 1.2 so long as backward compatibility is easy to
maintain.)  Unless the function does more than is shown, it'd be hard to do
this without an unappealing, brute-force method.

Storing variables via ()'s (in $1, etc.) seems one possible way, but I don't
know how much work that is, since I've never implemented such a system.  I'm
going to go over the module and see about implementing this, but I wanted to
ask about it here before I spend too much time on it.

Also, why not specify case-ness in the match (with the default case-sensative)
via a letter appended to the closing '/' -- a la Perl's match operator?
 Compact, consistent with what users would likely expect, it avoids the need
for another argument, and it'd be easy to expand if needed.

In any case --

Ed Korthof
ed@organic.com

Re: Putting the date into the referer log.

Posted by Paul Sutton <pa...@ukweb.com>.
On Sun, 3 Nov 1996, Brian Behlendorf wrote:
> I like this.  Generalization is almost always a good thing.  :)  
> I could easily see
> 
>   HeaderMatch User-Agent /^Mozilla/ netscape=yes

Ok, here is a first draft of my 'mod_setenvif'. I've called the directive
SetEnvIf rather than HeaderMatch because it is capable of much more than
just matching on headers (and it is functionally similar to a conditional
SetEnv module, although it uses BrowserMatch syntax for setting env-vars,
not SetEnv). So the example becomes

  SetEnvIf User-Agent /^Mozilla/ netscape=yes

There is a SetEnvIfNoCase to correspond with BrowserMatchNoCase. I'd
prefer to make case-ness an argument, but passing more than three gets
tricky. This module already needs an extra options argument, ITERATE3
(patch also enclosed).

> The next question is, do we need access to other types of info, such as
> remote_host?  Paul needs it for his host-based logging.  What else would really
> be needed?  Request time?  

There are a few examples in the module: remote_host, remote_addr,
remote_user, request_uri and request_method. These are similar to the
envvars passed to CGI and SSI, or the names used in mod_rewrite. 

Paul
UK Web Ltd


Re: Putting the date into the referer log.

Posted by Brian Behlendorf <br...@organic.com>.
On Thu, 24 Oct 1996, Paul Sutton wrote:
> I agree about being careful here, but I think there is a case for adding a
> directive to set an env var based on artibrary headers, a generic form of
> BrowserMatch. The generic functionality will be useful with far more than
> just config logs.

I like this.  Generalization is almost always a good thing.  :)  
I could easily see

  HeaderMatch User-Agent /^Mozilla/ netscape=yes

or whatever instead of

  BrowserMatch /^Mozilla/ netscape=yes

The next question is, do we need access to other types of info, such as
remote_host?  Paul needs it for his host-based logging.  What else would really
be needed?  Request time?  

Anyways, if other folks think this at least the first option is a good idea, we
should move soon, before "BrowserMatch" becomes something we need to
backwards-support.

	Brian

--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--
brian@organic.com  www.apache.org  hyperreal.com  http://www.organic.com/JOBS


Re: Putting the date into the referer log.

Posted by Paul Sutton <pa...@ukweb.com>.
On Wed, 23 Oct 1996, Brian Behlendorf wrote:
> On Wed, 23 Oct 1996, Michael Smith wrote:
> > I guess I could go for adding ConfigIgnore to mod_log_config and then
> > keeping two logs.  In fact by this approach, mod_log_referer could
> > vanish couldn't it?
>
> Be careful of the slippery slope of turning the configurable logfile language
> into a full on language... first it'll be ConfigIgnore for some pattern match
> against the output, then it'll be ConfigIgnore for some pattern match against a
> particular variable, then we'll want to conditionalize based upon an or'd
> comparison of two variables, and then... we'll end up with a pretty full
> language on our hands, developed in the worst possible way, by committee and
> piecemeal.

I agree about being careful here, but I think there is a case for adding a
directive to set an env var based on artibrary headers, a generic form of
BrowserMatch. The generic functionality will be useful with far more than
just config logs.

Being able to ignore certain hosts when logging is a pretty common
request. The problem is that since config_log can now create multiple
logs, a simple LogIgnore directive won't work -- we probably want to be
able to configure different log files differently.

I think the way to do this is to employ the BrowserMatch idea... set an
env var, and make TransferLog & CustomLog only log if a variable is set
(or not set).  You'd need to be able to set an env var based on the remote
host name, though. Something like:

   RefererMatch .local.com forgetme
   RefererMatch .myisp.com forgetme

   TransferLogIf !forgetme logs/referer

to not log referrals from the local sites.

Now, I don't like the idea of RefererMatch much, since you'd have to add
directives for all sorts of matches (HostMatch to ignore requests from
particular hosts, for instance). Perhaps a generic env var setting
directive is needed, which can access all the request headers and other
attributes (such as the remote hostname/IP), and do regexp matching, e.g.

  If remote_host = .local.com local
  If remote_host = .myisp.com local

  TransferLogIf  local logs/access_log.local
  TransferLogIf !local logs/access_log

Then of course this would also be accessible to CGI's (just like the
BrowserMatch stuff), so they could easily check for 'local' accesses (if
($ENV{local}) { print "Internal information here... " } ).

Paul
UK Web


Re: Putting the date into the referer log.

Posted by Brian Behlendorf <br...@organic.com>.
On Wed, 23 Oct 1996, Michael Smith wrote:
> Ben Laurie wrote:
> > 
> >
> > Use mod_log_config...
> > 
> > Cheers,
> > 
> > Ben.
> 
> I only want to keep a log of referers where the referer is another site.
> With mod_log_referer I can do this using RefererIgnore.  It doesn't seem
> to be so easy with mod_log_config.
> 
> I guess I could go for adding ConfigIgnore to mod_log_config and then
> keeping two logs.  In fact by this approach, mod_log_referer could
> vanish couldn't it?

Be careful of the slippery slope of turning the configurable logfile language
into a full on language... first it'll be ConfigIgnore for some pattern match
against the output, then it'll be ConfigIgnore for some pattern match against a
particular variable, then we'll want to conditionalize based upon an or'd
comparison of two variables, and then... we'll end up with a pretty full
language on our hands, developed in the worst possible way, by committee and
piecemeal.  

I think the current capability of mod_log_config is plenty; filters (such as, I
don't care to see referers from myself) can be applied with rather simple perl
scripts after the fact.

Actually, there is one final capability I'd like to see in mod_log_config,
which would be hard to apply after logging: I'd like to have a
ConfigLogTranslate directive so that I can make sure whatever character I use
to delimit elements of the logged transaction doesn't end up a part of those
elements anyways.  I.e., at Organic we use a '|' to delimit the different
elements, and the only place that really tends to show up is in referers from
people's bookmarks (i.e.
file:/C|/windows/program_files/netscape/bookmarks.html or whatever).  I hacked
up mod_log_config to translate all '|''s in arguments to '/', I don't mind
keeping this proprietary hack but a generalized ConfigLogTranslate directive
would be useful.

	Brian

--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--
brian@organic.com  www.apache.org  hyperreal.com  http://www.organic.com/jobs


Re: Putting the date into the referer log.

Posted by Michael Smith <mj...@cursci.co.uk>.
Ben Laurie wrote:
> 
>
> Use mod_log_config...
> 
> Cheers,
> 
> Ben.

I only want to keep a log of referers where the referer is another site.
With mod_log_referer I can do this using RefererIgnore.  It doesn't seem
to be so easy with mod_log_config.

I guess I could go for adding ConfigIgnore to mod_log_config and then
keeping two logs.  In fact by this approach, mod_log_referer could
vanish couldn't it?

Mike