如果我需要在server里面定义日志,该怎么实现呢,如下
user www; worker_processes 2; google_perftools_profiles /var/tmp/nginx/tcmalloc/tcmalloc; events { use epoll; worker_connections 51000; } http { include mime.types; default_type application/octet-stream; keepalive_timeout 65; sendfile on; tcp_nopush on; tcp_nodelay on; client_header_timeout 10; client_body_timeout 10; send_timeout 10; gzip on; gzip_min_length 1k; gzip_buffers 4 16k; gzip_http_version 1.1; gzip_comp_level 2; gzip_types text/plain application/x-Javascript text/css applocation/xml; server { listen 80; server_name localhost; location / { root html; index index.html index.htm; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } location ~ \.php$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /usr/html$fastcgi_script_name; include fastcgi_params; } access_log /var/log/nginx/access2.log; 此处定义的日志格式,不需要在后面加日志格式 } 注意,下面的日志是放在server之外的,即出现警告是放的位置不对 log_format welog '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log weblog; }更多nginx日志问题,参考nginx的wiki:
最终于解决问题的是这个url