Results 1 to 3 of 3

Thread: Oddball Apache help (log files)

  1. #1
    the admiral formerly known as overclocked OC's Avatar
    Join Date
    Aug 2000
    Location
    Julian, NC
    Posts
    5,923

    Question Oddball Apache help (log files)

    I'd like to be able to exclude certain IPs from the Apache web logs. For example, I have no need to know that Apache has served files to my main box at home, 192.168.1.1. Is there any way to do this?

    tia

    -OC

  2. #2
    Rear Admiral Lower Half Cubsfan's Avatar
    Join Date
    Jul 2001
    Location
    Colorado
    Posts
    2,743
    Conditional Logging
    There are times when it is convenient to exclude certain entries from the access logs based on characteristics of the client request. This is easily accomplished with the help of environment variables. First, an environment variable must be set to indicate that the request meets certain conditions. This is usually accomplished with SetEnvIf. Then the env= clause of the CustomLog directive is used to include or exclude requests where the environment variable is set. Some examples:

    # Mark requests from the loop-back interface
    SetEnvIf Remote_Addr "127\.0\.0\.1" dontlog
    # Mark requests for the robots.txt file
    SetEnvIf Request_URI "^/robots\.txt$" dontlog
    # Log what remains
    CustomLog logs/access_log common env=!dontlog
    As another example, consider logging requests from english-speakers to one log file, and non-english speakers to a different log file.

    SetEnvIf Accept-Language "en" english
    CustomLog logs/english_log common env=english
    CustomLog logs/non_english_log common env=!english
    Although we have just shown that conditional logging is very powerful and flexibly, it is not the only way to control the contents of the logs. Log files are more useful when they contain a complete record of server activity. It is often easier to simply post-process the log files to remove requests that you do not want to consider.
    http://httpd.apache.org/docs/logs.html

  3. #3
    the admiral formerly known as overclocked OC's Avatar
    Join Date
    Aug 2000
    Location
    Julian, NC
    Posts
    5,923
    Damn, you quick. Thanks!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •