Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
nginx
GitHub Repository: nginx/nginx.org
Path: blob/main/xml/cn/docs/debugging_log.xml
1 views
1
<!--
2
Copyright (C) Igor Sysoev
3
Copyright (C) Nginx, Inc.
4
-->
5
6
<!DOCTYPE article SYSTEM "../../../dtd/article.dtd">
7
8
<article name="调试日志"
9
link="/cn/docs/debugging_log.html"
10
lang="cn"
11
rev="1">
12
13
14
<section>
15
16
<para>
17
要开启调试日志,首先需要在配置nginx时打开调试功能,然后编译:
18
19
<programlisting>
20
./configure --with-debug ...
21
</programlisting>
22
23
然后在配置文件中设置<literal>error_log</literal>的级别为<literal>debug</literal>
24
25
<programlisting>
26
error_log /path/to/log debug;
27
</programlisting>
28
29
nginx的windows二进制版本总是将调试日志开启的,因此只需要设置<literal>debug</literal>的日志级别即可。
30
</para>
31
32
<para>
33
注意,重新定义错误日志时,如过没有指定<literal>debug</literal>级别,调试日志会被屏蔽。下面的例子里,在<link doc="http/ngx_http_core_module.xml" id="server"/>层中重新定义的日志就屏蔽了这个虚拟主机的调试日志:
34
<programlisting>
35
error_log /path/to/log debug;
36
37
http {
38
server {
39
error_log /path/to/log;
40
...
41
</programlisting>
42
为了避免这个问题,注释这行重新定义日志的配置,或者也给日志指定<literal>debug</literal>级别:
43
<programlisting>
44
error_log /path/to/log debug;
45
46
http {
47
server {
48
error_log /path/to/log debug;
49
...
50
</programlisting>
51
</para>
52
53
<para>
54
另外,也可以只针对<link doc="ngx_core_module.xml" id="debug_connection">选定的客户端地址</link>开启调试日志:
55
56
<programlisting>
57
error_log /path/to/log;
58
59
events {
60
debug_connection 192.168.1.1;
61
debug_connection 192.168.10.0/24;
62
}
63
</programlisting>
64
</para>
65
66
</section>
67
68
</article>
69
70