Separate Log for Robot Page Access

Maxim Dounin mdounin at mdounin.ru
Sun Feb 7 00:31:25 MSK 2010


Hello!

On Sat, Feb 06, 2010 at 02:32:23AM -0800, Wohbah wrote:

> 
> What about a variable?  There is no conditional in the location block.
> 
>         set $logchoice       /var/log/nginx/access.log;
>         if ( $is_robot ~ T ) {
>             set $logchoice   /var/log/nginx/robots.log;
>         }
> 
>         location / {
>           access_log  $logchoice;
>           ...
>           try_files /maintenance.html $uri.html @phptry ;
>         }

This will work as expected though it implies overhead of 
calculating logpaths and opening them for every request.  You may 
consider using "if" with "rewrite ... last" or "return ..." in 
location blocks instead.

> <editorial>
> Conditionals are fundamental.  Imagine a CPU without one.  Lack of
> conditionals makes makes me ill.  One of the few things not to like about
> nginx.  Mabye *location* is evil ... but not conditionals.  If nginx
> conflicts with computer science, the flaw is not in compsci.

CPU allows only one thing to be done conditionally: jump to 
another instruction address.  This is exacly what is now may be 
done safely in nginx: you may jump to another location block.

And, just in case you haven't noticed it: location *is* 
conditional directives.  They allow you to select configuration 
depending on request uri.

The topic I pointed you to just explains one simple thing: "if" 
directive in nginx as currently implemented doesn't do what you 
expect and should be avoided.  The only safe things which may be 
done are specially outlined.

Maxim Dounin

> Now, avoiding "if" over labor effort, OK, that is a legitimate and good
> reason!  In fact, it's a much better reason than denying fundamental
> compsci.
> 
> But it means ugly software.  Nginx foists complexity onto user .conf files. 
> Which, as you say, work inconsistently (more ugliness).
> 
> Still, thank you nginx for wonderful software.  It sometimes seems like a
> baby with a rash, you just want it to heal so there's less diaper changing.
> </editorial>
> 
> -- 
> View this message in context: http://n2.nabble.com/Separate-Log-for-Robot-Page-Access-tp4524448p4524797.html
> Sent from the nginx mailing list archive at Nabble.com.
> 
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://nginx.org/mailman/listinfo/nginx



More information about the nginx mailing list