0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

httpd: Content-typeや処理時間を access_logに記載する

0
Posted at

やりたいこと

httpd(apache2.4)がブラウザに返却するコンテンツのヘッダ情報(Content-type)や処理時間が知りたい。

  • ”Content-Type"を知ることで、Deflateする対象がわかったり(ここで利用)
  • 処理時間がわかることで、プログラムの遅延対象が判明する

実現手順

コンフィグファイル修正

Customlogで指定しているフォーマット(今回の例ではcombined)のLogFormatディレクティブに追記する。

httpd.conf(修正前)
...
<IfModule log_config_module>
    ...
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    ...
    CustomLog "logs/access_log" combined
</IfModule>
...
フォーマット 説明
%D リクエストを処理するのにかかった時間、マイクロ秒単位(今回はこっちを採用)
%T リクエストを処理するのにかかった時間、秒単位
%{Content-Type}o 応答のヘッダの Content-Type: の中身
httpd.conf(修正後)
...
<IfModule log_config_module>
    ...
    LogFormat "%h %l %u %t \"%r\" %>s %b %D \"%{Content-Type}o\" \"%{Referer}i\" \"%{User-Agent}i\"" combined
    ...
    CustomLog "logs/access_log" combined
</IfModule>
...

再起動

# service httpd restart

参考

LogFormatに記載するフォーマットが多数記載されています。用途に応じて利用しましょう。

Apache モジュール mod_log_config

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?