1) 在nginx日志access log可以記錄POST請求的參數值
實現程度:日志中可以顯示POST請求所提交的參數值
問題:
- 日志中文顯示十六進制(在配置文件中配置中文也無效)
- 沒有對json數據進行測試,正文類型為:Content-Type: application/x-www-form-urlencoded; charset=UTF-8
配置說明:
log_format指令用來設置日志的記錄格式,語法:
log_format name format {format ...}
其中name表示定義的格式名稱,需要保持一致,format表示定義的格式樣式。
配置:
1.在nginx.conf 的http{}里面加上$request_body
如:
log_format name '$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent $request_body "$http_referer" "$http_user_agent" $http_x_forwarded_for';
- 在service添加訪問日志的輸出(米德環境中已經配置)
access_log 日志路徑 name;
- 在server中設置location /{try_files}
其中try——files的語法是:try_files file…uri,,沒有默認值,作用域是server location
2)利用nginx+lua實現通用的請求實現輸入輸出日志的打印,這個方法沒有進行測試,但找到了相關的配置鏈接,根據鏈接1配置測試時沒有成功。
1. https://blog.csdn.net/MICweaver/article/details/66473183
2.安裝lua方法https://www.cnblogs.com/YiXiaoZhou/p/6274033.html
3. nginx+lua+mysql實時存日志https://blog.csdn.net/guoyuguang0/article/details/76768924