nginx的日志文件配置
生活随笔
收集整理的這篇文章主要介紹了
nginx的日志文件配置
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
1)與nginx日志相關(guān)的指令有兩條:log_format 和 access_log;
log_format 設(shè)置日志格式;
access_log 指定日志文件存放路徑;
2)log_foramt
2.1)指令參數(shù):
log_format combined '$remote_addr - $remote_user [$time_local]'
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent"';
2.2)增加 X-Forwarded-For 信息, 用來記錄原有的客戶端ip地址和原來客戶端請求的服務(wù)器地址, 如下:
log_format combined '$http_x_forwarded_for - $remote_user [$time_local]'
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent"';
3)access_log
3.1)指令參數(shù):
access_log path [format [buffer=size | off]]
path表示日志文件存放路徑, format表示日志格式名稱, buffer表示內(nèi)存緩沖區(qū)大小;
3.2)關(guān)閉日志: access_log off;
3.3)使用默認(rèn)的 combined格式的日志記錄,如下:
access_log /data1/logs/filename.log;
或?
access_log /data1/logs/filename.log combined;
3.4)使用自定義格式的日志記錄;
log_format 設(shè)置日志格式;
access_log 指定日志文件存放路徑;
2)log_foramt
2.1)指令參數(shù):
log_format combined '$remote_addr - $remote_user [$time_local]'
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent"';
2.2)增加 X-Forwarded-For 信息, 用來記錄原有的客戶端ip地址和原來客戶端請求的服務(wù)器地址, 如下:
log_format combined '$http_x_forwarded_for - $remote_user [$time_local]'
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent"';
3)access_log
3.1)指令參數(shù):
access_log path [format [buffer=size | off]]
path表示日志文件存放路徑, format表示日志格式名稱, buffer表示內(nèi)存緩沖區(qū)大小;
3.2)關(guān)閉日志: access_log off;
3.3)使用默認(rèn)的 combined格式的日志記錄,如下:
access_log /data1/logs/filename.log;
或?
access_log /data1/logs/filename.log combined;
3.4)使用自定義格式的日志記錄;
總結(jié)
以上是生活随笔為你收集整理的nginx的日志文件配置的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: nginx停止,平滑重启命令
- 下一篇: css怎么设置数字字体(css怎么设置数