---
title: "nginx 日志设置  FOR error_log "
author: "sinykk"
date: "2011-06-03T09:34:21Z"
tags: ["Access", "PHP", "nginx"]
categories: ["编程语言"]
slug: "nginx-for-error-log"
draft: false
lastmod: "2011-06-03T09:34:21Z"
id: 1069273
url: "https://sinykk.iteye.com/blog/1069273"
---

在你配置的NGINX nginx.conf中加入如下代码

 

         log\_format  access  '$remote\_addr - $remote\_user \[$time\_local] "$request" '  
             '$status $body\_bytes\_sent "$http\_referer" '  
             '"$http\_user\_agent" $http\_x\_forwarded\_for';  
        access\_log  /home/wwwlogs/access.log  access;  
        error\_log logs/nginx\_error.log  debug;  
        error\_page 404 = /404.php;

 

 

error\_log 日志分为

nginx的log有以下几种类型： \[ debug | info | notice | warn | error | crit ]   
在nginx.conf的设置：error\_log logs/error.log  debug;  
debug 为最详细 crit最少

 

在页面里使用 error\_log('this is error log') 方法方便调试程序