 |
|
Log Files
Oracle Application Server Tips by Burleson
Consulting |
The next section of the httpd.conf file
defines log locations, logging levels, and formats. Logging
levels determine how much information is logged. The greater the
level, the more information and the logs grow faster.
HostnameLookups Off
ErrorLog
/home/oracle/oraportal904/Apache/Apache/logs/error_log
LogLevel warn
You can have OHS log the host name instead
of the IP address, but that is not recommended since OHS must hit
the DNS to resolve the IP address. The default is
HostnameLookups Off , which logs the IP address instead of the host
name. The ErrorLog directive establishes where the error log
is located and the LogLevel determines how much information is
logged. The levels of logging in descending order of verbosity
are:
Level
Description
Example
emerg
Emergencies - system is unusable.
"Child cannot open lock file. Exiting"
alert
Action must be taken immediately.
"getpwuid: couldn't determine user ?"
crit
Critical Conditions.
"socket: Failed to get a socket, exiting child"
error
Error conditions.
"Premature end of script headers"
warn
Warning conditions.
"child process 1234 did not exit "
notice
Normal but significant condition.
"httpd: caught SIGBUS, attempting to ??
info
Informational.
"Server seems busy?
debug
Debug-level messages
"Opening config file ..."
The selected level will log those items and all items above
the selected level.
Another important log is the access_log
file. OHS uses the module mod_log_config to log each request
in the access_log file, normally located in ServerRoot/logs/access_log.
The first step is to define one or more
LogFormats. The LogFormat directive can take one or two
arguments. If there is only one argument (the formatting
variables), then it will be used in all subsequent TransferLog
directives. If there are two arguments (the formatting
variables and an alias), then subsequent TransferLog and CustomLog
directives can use the alias to define the format to use.
In the httpd.conf file, Oracle has defined
four formats with the LogFormat directive aliased by: combined,
common, referrer, and agent. Next, the CustomLog directive is used
to assign the ?common? format to the access_log file.
LogFormat
"%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\""
combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
LogFormat "%{Referer}i -> %U" referrer
LogFormat "%{User-agent}i" agent
CustomLog /home/oracle/oraportal904/Apache/Apache/logs/access_log
common
The CustomLog directive establishes the log
location and format. In the example above, CustomLog defines
the location of the access_log file, and that it will use the format
aliased by ?custom?. It could also directly define the format
rather than use the format alias.
TransferLog functions like CustomLog, except
that TransferLog takes the format of the last defined LogFormat
without an alias, or if no LogFormat exists without an alias, it
uses the Common Log Format (the default format). We will see
an example of TransferLog in the Virtual Host section.
There can be multiple CustomLog/TransferLog
directives, but OHS will only use the last one found, except in the
case of a Virtual Host, which can have its own log file, format, and
location.
There is one last important note about the
access_log file. This file constantly grows, because every
request received by the server is logged. To speed this
logging, OHS maintains the file offset for the next write. If
you delete the file, OHS will open a new file and write to the
stored offset, which means that the new file will start as large as
the deleted file but will be totally empty. To fix this, you
must ?reset? the log file by removing it, and then signal OHS using
the SIGHUP (-1) signal.
mv
access_log access_log.bak
kill ?1 ?cat httpd.pid?
This will move and rename the old access_log
file and cause OHS to create a new file when it logs a new request.
The file httpd.pid contains the operating system process id for the
parent OHS process.
Aliases
The next section of the httpd.conf file
deals with aliases. OHS uses the module mod_alias to allow the
use of directories not under DocumentRoot. One important note
about using aliases is that if they end in a ?/?, then the
subdirectory itself is not aliased. For example, we see below
that ?/icons/? is aliased, so a request for //myserver/icons/oracle/OracleWorld.gif
will work, but //myserver/icons/OracleWorld.gif will not because of
the trailing ?/?.
<IfModule
mod_alias.c>
Alias /icons/
"/home/oracle/oraportal904/Apache/Apache/icons/"
Alias /jservdocs/ "/home/oracle/oraportal904/Apache/Jserv/docs/"
Alias /javacachedocs/ "/home/oracle/oraportal904/javacache/javadoc/"
<IfModule mod_perl.c>
Alias /perl/
"/home/oracle/oraportal904/Apache/Apache/cgi-bin/"
</IfModule>
<Directory "/home/oracle/oraportal904/Apache/Apache/icons">
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
ScriptAlias /cgi-bin/ "/home/oracle/oraportal904/Apache/
Apache/cgi-bin/"
Another important point is that using
aliases opens additional subdirectories for use and thus, may
require Directory containers to define access. If no Directory
containers are given for the new locations, then the access will
default to the access granted the root ?/? directory.
ScriptAlias (at the bottom of the example)
works in the same manner as Alias, except that OHS will execute the
script/application instead of sending it as a page to the requester.
The AliasMatch directive is not shown in the
example but is another powerful tool. It allows the use of
regular expressions instead of just prefix matching.
AliasMatch
^/icons(.*) /usr/local/apache/icons$1
OHS substitutes the parenthesized matches
into the string $1 and uses it to identify filenames.
The Redirect directive will take a matching
request and send the client a new URL, causing the client to
re-request from the new location.
Redirect
/joke http://fun.house.com/jokes
Here, a client requesting
http://myserver/jokes/good_one.txt would be redirected to
http://fun.house.com/jokes/good_one.txt. To include
regular expressions, use the RedirectMatch directive. The
Redirect directive can also contain a status, such as Permanent or
301, Temporary or 302, See Other or 303, or Gone or 410. In
the cases where a document is permanently removed, you would want to
use ?gone? and leave off the URL.
Redirect
permanent /joke
http://fun.house.com/jokes
Redirect 301 /joke
http://fun.house.com/jokes
Redirect gone /joke
Indexing and FancyIndexing
The next section of the httpd.conf file
deals with indexing. Indexing in OHS has nothing to do with
indexing in an Oracle database.
When OHS gets a request for a directory, it
looks for a file called index.html. If it is present, then OHS
uses it, if it is not present then OHS creates an index or catalog
of the directory and serves that. To create this index, OHS
uses the module mod_autoindex. OHS will not create an index if
the Options directive for that directory does not include +Indexes.
The httpd.conf file contains a DirectoryIndex directive that
establishes what OHS should do if a request resolves to a directory
instead of a file.
<IfModule
mod_dir.c>
DirectoryIndex index.html
</IfModule>
Following this directive, OHS will look for
a file called index.html. If it is not present, OHS will check the
directory for Options +Indexes and if present, will use
mod_autoindex to create a listing of the directory and serve that
listing.
The DirectoryIndex directive can have a list
of space-separated files and OHS will attempt to locate each of the
files in order before creating its own listing. If you do not
want a server-created listing of the file, you can place an error
file at the end of the DirectoryIndex list that will be served if
the previous file is not found.
DirectoryIndex index.html welcome.html goodby.html standard/error.html
Once OHS has exhausted the options defined
in DirectoryIndex and the directory Options +Indexes is valid, then
it must create the index or file list.
One important directive is IndexIgnore.
The IndexIgnore directive allows you to stop mod_autoindex from
including certain files, such as backup files or files that begin
with a ?dot?, such as the .htaccess file. Multiple
IndexIgnores add files to the exclude list and do not overwrite each
other.
IndexIgnore .htaccess README* *.bak
The
httpd.conf file contains a detailed listing for FancyIndexing which
creates a format for the OHS generated index listing. If you
wish to modify this listing, please refer to the Apache
documentation (Google ?Apache mod_autoindex?).
This is an excerpt from "Oracle
10g Application Server Administration Handbook" by Don Burleson
and John Garmany.