nginx日志格式


nginx 日志格式

log_format 有個默認的日志格式:

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

** nginx 默認調用 combined 格式來記錄日志,即默認調用:(默認記錄在access.log文件中)**

access_log logs/access.log combined;

nginx允許自定義日志格式,例如:

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

以上是自定義了日志格式:main(main名稱可以自定義)

要想使其生效,就必須用access_log指定調用:

access_log logs/xx.log main;

iamge
否則,nginx仍然會去調用combined格式來記錄日志。

更多日志的介紹


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM