blob: 70050d0073ea2eba7ec0d9d3563ba0f40cdb09d0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
|
=encoding utf-8
=head1 Name
debugging_log - A debugging log
=head1
To enable a debugging log, nginx needs to be configured to support
debugging during the build:
./configure --with-debug ...
Then the C<debug> level should be set with the
L<ngx_core_module> directive:
error_log /path/to/log debug;
To verify that nginx is configured to support debugging,
run the C<nginx -V> command:
configure arguments: --with-debug ...
Pre-built L<Linux|linux_packages> packages
provide out-of-the-box support for debugging log with
the C<nginx-debug> binary (1.9.8)
which can be run using commands
service nginx stop
service nginx-debug start
and then set the C<debug> level.
The nginx binary version for Windows is always built with the debugging log
support, so only setting the C<debug> level will suffice.
Note that redefining the log without also specifying the
C<debug>
level will disable the debugging log.
In the example below, redefining the log on the
L<ngx_http_core_module>
level disables the debugging log for this server:
error_log /path/to/log debug;
http {
server {
error_log /path/to/log;
...
To avoid this, either the line redefining the log should be
commented out, or the C<debug> level specification should
also be added:
error_log /path/to/log debug;
http {
server {
error_log /path/to/log debug;
...
=head1 Debugging log for selected clients
It is also possible to enable the debugging log for
L<selected
client addresses|ngx_core_module> only:
error_log /path/to/log;
events {
debug_connection 192.168.1.1;
debug_connection 192.168.10.0/24;
}
=head1 Logging to a cyclic memory buffer
The debugging log can be written to a cyclic memory buffer:
error_log memory:32m debug;
Logging to the memory buffer on the C<debug> level
does not have significant impact on performance even under high load.
In this case, the log can be extracted using
a C<gdb> script like the following one:
set $log = ngx_cycle->log
while $log->writer != ngx_log_memory_writer
set $log = $log->next
end
set $buf = (ngx_log_memory_buf_t *) $log->wdata
dump binary memory debug_log.txt $buf->start $buf->end
Or using an C<lldb> script as follows:
expr ngx_log_t *$log = ngx_cycle->log
expr while ($log->writer != ngx_log_memory_writer) { $log = $log->next; }
expr ngx_log_memory_buf_t *$buf = (ngx_log_memory_buf_t *) $log->wdata
memory read --force --outfile debug_log.txt --binary $buf->start $buf->end
|