sleepingbird.net Home since May.11 2003
Copyright sleepingbird, 1993- All rights reserved.
Linux Server

TOP > Linux Server > Web server > ログのカスタマイズ

ログのカスタマイズ

 サーバを運営していて、たまにログを覗くと思ったより膨大なデータが記録されている。しかし、良く見るとそのほとんどがアクセスしたページに付随する画像ファイル等のアクセス記録である。設定当初は稼働状況を詳細にチェックするのにログ情報は多いほどありがたいが、安定稼働状態だと逆にうっとうしい。そこで、これらの出力を抑止する。
 SetEnvIfを使用することとし、環境変数「rejectlog」にログに出力したくないファイルの拡張子を登録し、CustomLog を変更する。

# reject log files
SetEnvIf Request_URI "\.(gif)|(jpg)|(png)|(js)|(css)$" rejectlog

#
# The location and format of the access logfile (Common Logfile Format).
# If you do not define any access logfiles within a <VirtualHost>
# container, they will be logged here. Contrariwise, if you *do*
# define per-<VirtualHost> access logfiles, transactions will be
# logged therein and *not* in this file.
#
# CustomLog /var/log/httpd/access_log common
#CustomLog /var/log/httpd/access_log combined
CustomLog /var/log/httpd/access_log combined env=!rejectlog