月別アーカイブ: 2014年9月




【基本】Apacheのアクセスログのカスタマイズ




投稿日:

Apacheのログは本当に自由自在で、なんでも書き出す事が可能です。
ここではその基本的な方法とそお考え方をメモしておきます。

設定場所はこちらです。

[html]less /etc/httpd/conf/httpd.conf

#
# The following directives define some format nicknames for use with
# a CustomLog directive (see below).
#
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" referer
LogFormat "%{User-agent}i" agent
[/html]

LogFormatとして、ログの出し方を定義して、それにニックネーム(combinedや、common、refererのこと)をつけておきます。

これにより、ログのフォーマットをバーチャルホスト毎にニックネームを書き出すだけで変えることが可能です。

LogFormatにて、ログの定義として使えるのは、こんなにあります。

mod_log_config – Apache HTTP サーバ バージョン 2.2

参考URL

ログファイル – Apache HTTP サーバ バージョン 2.2