apacehのアクセスログのLogFormatについて完全に自分用のメモ
今のを確認
# cat /usr/local/apache2.4/conf/httpd.conf | grep LogFormat -C 3
LogLevel warn
<IfModule log_config_module>
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %D" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
<IfModule logio_module>
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O %D" combinedio
</IfModule>
CustomLog "|/usr/local/sbin/cronolog /apache/logs/access_log.%Y-%m-%d" common
</IfModule>
IfModuleについて
モジュールが組み込まれているときの処理
!をつけるとモジュールが組み込まれていない場合
IFModuleで判定されてるモジュールが組み込まれているか確認
# sudo /apache/bin/apachectl -M | egrep "log_config_module|logio_module" log_config_module (shared)
LogFormatを理解
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %D" combined
の部分について自分メモ
左から順番に
| 変数 | 解説 |
| %h | リモート・ホスト名 |
| %l | (identdからもし提供されていれば) リモートログ名。 |
| %u | ユーザ認証によるリモート・ユーザ名 |
| %t | アクセス日時 |
| %r | HTTPリクエストヘッダー |
| %>s | ステータスコード |
| %{Referer}i | ヘッダーの中の「Referer」の値 |
| %{User-Agent}i | ヘッダーの中の「User-Agent」の値 |
| %D | リクエストを処理するのにかかった時間、マイクロ秒単位 |
参考