LoginSignup
35
38

More than 5 years have passed since last update.

[備忘録]nginxでデバッグ出力

Posted at

log_formatを定義している所に、以下のように、debug_log_fmtを追加

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    log_format debug_log_fmt "[DEBUG][$time_local] $dbg_v";

デバッグ出力したい所で、$dbg_vに値をセットし、access_logで指定パスに書き込む

         set $dbg_v "hoge hoge hoge...";
         access_log /var/log/nginx/debug.log debug_log_fmt;

すると、/var/log/nginx/debug.logに以下のように出力する。

[DEBUG][06/Mar/2014:12:30:16 +0900] hoge hoge hoge...
35
38
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
35
38