Translate

How to filter logs in lighttpd

I usually don’t keep lighttpd access logs turned on to avoid writing for every read, but there are times when you need to monitor what’s going on, and you’d like to have a high signal-to-noise ratio so it might be convenient to ignore all requests to .gif, .png, .jpg, .css, .ico and other urls on your webserver.

To only log certain files, or to NOT log certain files, you resolve this the same way as you do every other thing in lighttpd… by matching lighttpd variables to regular expressions and applying the settings where they match.

# www -> the main website
$HTTP["host"] =~ "^www.yoursite.com$" {
  server.document-root = "/var/www/www.yoursite.com"
  server.errorlog = "/var/log/lighttpd/www.yoursite.com/error.log"

  #Only log non-css and images
  <strong>$HTTP["url"] !~ "(\.css|\.jpg|\.gif|\.png|\.ico)$" {
    accesslog.filename = "/var/log/lighttpd/www.yoursite.com/access.log"
  }</strong>
}

So in this example, we only log, where the URL doesn’t end with any of the “.css”, “.jpg”, “.gif”, “.png” or “.ico” extensions. We filter those out.

Hope this works for you.

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

One Response to “How to filter logs in lighttpd”

  1. Enlaces que os pueden interesar Says:

    [...] Filtrar logs en lighttpd [...]

Leave a Reply