3 # ====================================================================
4 # Copyright (c) 1995-1999 The Apache Group. All rights reserved.
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
10 # 1. Redistributions of source code must retain the above copyright
11 # notice, this list of conditions and the following disclaimer.
13 # 2. Redistributions in binary form must reproduce the above copyright
14 # notice, this list of conditions and the following disclaimer in
15 # the documentation and/or other materials provided with the
18 # 3. All advertising materials mentioning features or use of this
19 # software must display the following acknowledgment:
20 # "This product includes software developed by the Apache Group
21 # for use in the Apache HTTP server project (http://www.apache.org/)."
23 # 4. The names "Apache Server" and "Apache Group" must not be used to
24 # endorse or promote products derived from this software without
25 # prior written permission. For permission please contact
28 # 5. Products derived from this software may not be called "Apache"
29 # nor may "Apache" appear in their names without prior written
30 # permission of the Apache Group.
32 # 6. Redistributions of any form whatsoever must retain the following
34 # "This product includes software developed by the Apache Group
35 # for use in the Apache HTTP server project (http://www.apache.org/)."
37 # THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
38 # EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
39 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
40 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE GROUP OR
41 # ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
42 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
43 # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
44 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
45 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
46 # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
47 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
48 # OF THE POSSIBILITY OF SUCH DAMAGE.
49 # ====================================================================
51 # This software consists of voluntary contributions made by many
52 # individuals on behalf of the Apache Group and was originally based
53 # on public domain software written at the National Center for
54 # Supercomputing Applications, University of Illinois, Urbana-Champaign.
55 # For more information on the Apache Group and the Apache HTTP server
56 # project, please see <http://www.apache.org/>.
60 # This script will take a combined Web server access
61 # log file and break its contents into separate files.
62 # It assumes that the first field of each line is the
63 # virtual host identity (put there by "%v"), and that
64 # the logfiles should be named that+".log" in the current
67 # The combined log file is read from stdin. Records read
68 # will be appended to any existing log files.
72 while ($log_line = <STDIN>) {
74 # Get the first token from the log record; it's the
75 # identity of the virtual host to which the record
78 ($vhost) = split (/\s/, $log_line);
80 # Normalize the virtual host name to all lowercase.
81 # If it's blank, the request was handled by the default
82 # server, so supply a default name. This shouldn't
83 # happen, but caution rocks.
85 $vhost = lc ($vhost) or "access";
87 # If the log file for this virtual host isn't opened
90 if (! $is_open{$vhost}) {
91 open $vhost, ">>${vhost}.log"
92 or die ("Can't open ${vhost}.log");
96 # Strip off the first token (which may be null in the
97 # case of the default server), and write the edited
98 # record to the current log file.
100 $log_line =~ s/^\S*\s+//;
101 printf $vhost "%s", $log_line;