Nginx Add Request Host In Log Format

Server environment

1
2
3
4
5
$ cat /etc/issue
Ubuntu 16.04.3 LTS

$ nginx -v
nginx version: nginx/1.10.3 (Ubuntu)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# cat nginx.conf 

user www-data;
worker_processes auto;
...
http {
...

##
# Logging Settings
##

log_format main '$host - $remote_addr - [$time_local] "$request" '
'$status $upstream_response_time $request_time "$http_referer"'
'"$http_user_agent" "$http_x_forwarded_for" $body_bytes_sent ';
access_log /var/log/nginx/access.log main;

It only take effect that main in access_log /var/log/nginx/access.log main; match the log format name.

# log, nginx

Thank you for reading.
This post is copyrighted by Liyuliang’s Blog.
If reproduced, please indicate the source: Liyuliang’s Blog
This blog uses Creative Commons Attribution-NonCommercial-Share-Sharing 4.0 International License Agreement to license.


Comments

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×