Apache-DBILogConfig-0.02 > Apache::DBILogConfig

名前

Apache::DBILogConfig - アクセス情報をDBIデータベースにログ出力

概要

 # httpd.confで
 PerlLogHandler Apache::DBILogConfig
 PerlSetVar DBILogConfig_data_source DBI:Informix:log_data
 PerlSetVar DBILogConfig_username    informix
 PerlSetVar DBILogConfig_password    informix
 PerlSetVar DBILogConfig_table       mysite_log
 PerlSetVar DBILogConfig_log_format  "%b=bytes_sent %f=filename %h=remote_host %r=request %s=status"

説明

このモジュールは標準のApacheモジュールmod_log_configの機能を複写しています。しかし ファイルではなくDBI互換性のあるデータベースに情報をログ出力します。 (ドキュメントの一部はmod_log_configから拝借してきました。)

トークン一覧

DBILogConfig_data_source

"DBI::driver:database"という形式のDBIデータソース。

DBILogConfig_username

接続するときにデータベース・ドライバに渡されるユーザ名

DBILogConfig_password

接続するときにデータベース・ドライバに渡されるパスワード

DBILogConfig_table

ログをとるためのデータベース上のテーブル

DBILogConfig_log_format

ログ出力されるデータを定義する空白で区切られた書式が入った文字列(下記の書式文字列をご覧ください)

書式文字列

書式文字列は以下のような書き方の文字列で構成されます:

%[条件][{パラメータ}]フォーマット=フィールド

フォーマット

Formats specify the type of data to be logged. The following formats are accepted:

a Remote IP-address
A Local IP-address (not yet supported)
B Bytes sent, excluding HTTP headers.
b Bytes sent, excluding HTTP headers. In CLF format i.e. a '-' rather than a 0 when no bytes are sent.
c Connection status when response is completed. 'X' = connection aborted before the response completed. '+' = connection may be kept alive after the response is sent. '-' = connection will be closed after the response is sent. (not yet supported)
e The contents of the environment variable specified by parameter
f Filename
h Remote host
H The request protocol
i The contents of the header (specified by parameter) in the request sent to the server.
l Remote logname (from identd, if supplied)
m The request method
n The contents of note (specified by parameter) from another module.
o The contents of the header (specified by parameter) in the reply.
p The canonical Port of the server serving the request
P The process ID of the child that serviced the request.
q The query string (prepended with a ? if a query string exists, otherwise an empty string)
r First line of request
s Status. For requests that got internally redirected, this is the status of the *original* request.
t Time, in common log format time format or the format specified by parameter, which should be in strftime(3) format.
T The time taken to serve the request, in seconds.
u Remote user (from auth; may be bogus if return status (%s) is 401)
U The URL path requested.
v The canonical ServerName of the server serving the request.
V The server name according to the UseCanonicalName setting (not yet supported).

フィールド

データがログ出力されるデータベースの列

パラメータ

パラメータを取る書式のためのもの

例: %{DOCUMENT_ROOT}e

条件

Conditions are a comma-separated list of status codes. If the status of the request being logged equals one of the status codes in the condition the data specified by the format will be logged. By placing a '!' in front of the conditions, data will be logged if the request status does not match any of the conditions.

Example: %!200,304,302s=status will log the status of all requests that did not return some sort of normal status

デバッグ

LOGLEVELが'warn'以上に設定されていると、デバッグのためのステートメントはエラーログに書き込まれます。

必要なもの

  • mod_perl >= PerlLogHandlerが利用可能になっている 1.11_01

  • DBI

  • Date::Format

インストール

このモジュールをインストールするためには、このファイルがあるディレクトリに 移動し、以下のようにタイプしてください:

        perl Makefile.PL
        make
        make test
        make install

これによりモジュールがPerlライブラリ・ディレクトリにインストールされます。

インストールしたら、Webサーバーの構成設定を上記のように変更する必要があります。

注意

このモジュールをインストールし設定した後でも、(以前、そのように設定されていたならば) Apacheは通常のアクセスログファイルにログを続けます。アクセスをデータベースにだけ ログ出力させるためには、CustomLogかTransferLogをコメント・アウトするか、それらを/dev/nullに 設定してください。

作者(=AUTHOR)

Copyright (C) 1998, Jason Bodnar <jason@shakabuku.org>. All rights reserved.

This module is free software; you may redistribute it and/or modify it under the same terms as Perl itself.

参考資料

perl(1), mod_perl(3)

翻訳者

川合孝典(GCD00051@nifty.ne.jp)