LoginSignup
12
13

More than 5 years have passed since last update.

Apache 2.4でPOSTの内容をログに出力するときは"LogLevel debug"だけじゃ出てこない

Last updated at Posted at 2016-01-31

tl;dr

  • dumpioモジュールを有効化し、InputとOutputを有効化
    • 場合に依ってはOutputは要らないかも
LoadModule dumpio_module modules/mod_dumpio.so
DumpIOInput On
DumpIOOutput On
  • LogLevelに dumpio:trace7 を追加(重要!!
LogLevel debug dumpio:trace7

検証環境

  • さくらのクラウド
  • CentOS7.2 テンプレート
  • yumでインストールしたApache
[root@web01 httpd]# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)
[root@web01 httpd]# httpd -v
Server version: Apache/2.4.6 (CentOS)
Server built:   Nov 19 2015 21:43:13

経緯

今まではdumpioモジュールを有効化した後、LogLevelをdebugにしておくと、各モジュールのデバッグ情報も出力されておりましたが、仕様が変わったようです。

  • 今までの記法
LogLevel debug
  • これからの記法
LogLevel debug dumpio:trace7

通常のログメッセージがdebug相当を必要としないなら、warnなどにしても問題無いです。

※問題無し!
LogLevel warn dumpio:trace7

ログ

こういうHTMLを用意

[root@web01 html]# cat -n index.html
     1  <!DOCTYPE HTML>
     2  <html>
     3          <head>
     4                  <meta charset="utf-8" />
     5          </head>
     6          <body>
     7
     8            <form method="POST">
     9                  <input type="text" name="name" >
    10                  <input type="email" name="email">
    11                  <textarea name="messeage" ></textarea>
    12                  <input type="submit" name="submit" value="Send Message">
    13            </form>
    14
    15    </body>
    16  </html>

手元から実行

whywaita% curl -X POST -F "name=hoge" -F "email=cat@example.com" -F "messe=test" http://example.com

エラーログにこういうログが出るようになります

[Sun Jan 31 11:46:25.379210 2016] [dumpio:trace7] [pid 3989] mod_dumpio.c(103): [client example.com:61852] mod_dumpio:  dumpio_in (data-HEAP): --------------------------b0d1a574a83c2f55\r\nContent-Disposition: form-data; name="name"\r\n\r\nhoge\r\n--------------------------b0d1a574a83c2f55\r\nContent-Disposition: form-data; name="email"\r\n\r\ncat@example.com\r\n--------------------------b0d1a574a83c2f5
5\r\nContent-Disposition: form-data; name="messe"\r\n\r\ntest\r\n--------------------------b0d1a574a83c2f55--\r\n

ドキュメント

結論

分からなくなったら翻訳ドキュメントを信じずに本家ドキュメント読もう

12
13
1

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
12
13