Debian Codegraph @

doc/howto/Tracing.html

raw symbols SCIP
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title>ProFTPD: Tracing</title>
5 </head>
6
7 <body bgcolor=white>
8
9 <hr>
10 <center><h2><b>ProFTPD: Tracing</b></h2></center>
11 <hr>
12
13 <p>
14 <b>What is Tracing?</b><br>
15 "Tracing" is a new form of logging, introduced in the 1.3.1 ProFTPD release
16 series.
17
18 <p>
19 Trace logging has the concept of multiple logging <i>channels</i>, each of
20 which has its own log <i>level</i>. Layers and APIs within the ProFTPD source
21 will tend to use their own channels. There is no limit to the number of
22 different log channels that can be supported.
23
24 <p>
25 Within a channel, the assumption is that lower log levels indicate higher
26 priority or importance. Or to look at it another way, the higher the log
27 level for channel, the more noisy that log channel might be. The lowest log
28 level is 1; there is no upper log level limit.
29
30 <p>
31 Why have this new form of logging, in addition to all the other kinds of logs
32 (<i>e.g.</i> <code>SystemLog</code>, <code>ExtendedLog</code>, <i>etc</i>)
33 that a <code>proftpd</code> daemon can currently produce? The usual
34 <code>SystemLog</code> of proftpd debug logging, at a high
35 <code>DebugLevel</code>, was becoming unreadable; it is difficult to find the
36 tidbits of knowledge amidst the other messages in that file. By separating
37 log messages into channels and levels, tracing gives the administrator a much
38 finer-grained control over the logging, given them a way of focusing the
39 logging more narrowly, so only the area of code of interest is logged.
40
41 <p>
42 Support for tracing is enabled by default. Use the
43 <code>--disable-trace</code> configure option, when compiling ProFTPD, to
44 disable all tracing support. I recommend that high-traffic production sites,
45 which have no need for debug logging at this granularity, use the
46 <code>--disable-trace</code> option.
47
48 <p>
49 <b>Configuration Directives</b><br>
50 There are two new configuration directives for tracing: <code>TraceLog</code>
51 and <code>Trace</code>. Note that for tracing to be effective, these
52 two directives, if used, <i>must</i> appear at the start of your
53 <code>proftpd.conf</code> file, before any other directives.
54
55 <p>
56 The <code>TraceLog</code> directive specifies a filename to which to write
57 the tracing log messages. For example:
58 <pre>
59 TraceLog /var/ftpd/trace.log
60 </pre>
61 Without this directive, no trace logging will occur.
62
63 <p>
64 Once you have configured your <code>TraceLog</code>, you will use the
65 <code>Trace</code> directive to control the verbosity of that log:
66 <pre>
67 Trace <i>channel1</i>:<i>level1</i> <i>channel2</i>:<i>level2</i> ...
68 </pre>
69 This directive lets you set each log channel and its level differently,
70 <i>e.g.</i>:
71 <pre>
72 Trace command:5 response:8 timer:2 config:9
73 </pre>
74 There is also support for a special "DEFAULT" keyword:
75 <pre>
76 Trace DEFAULT:10
77 </pre>
78 The following is the list of channels which are covered by the "DEFAULT"
79 keyword:
80 <ul>
81 <li>auth
82 <li>binding
83 <li>command
84 <li>config
85 <li>ctrls
86 <li>data
87 <li>delay
88 <li>dns
89 <li>dso
90 <li>encode
91 <li>error
92 <li>event
93 <li>facl
94 <li>fsio
95 <li>ident
96 <li>inet
97 <li>lock
98 <li>log
99 <li>module
100 <li>netacl
101 <li>netio
102 <li>pam
103 <li>pool
104 <li>regexp
105 <li>response
106 <li>scoreboard
107 <li>signal
108 <li>site
109 <li>timer
110 <li>var
111 </ul>
112 This means that if you use the following in your <code>proftpd.conf</code>
113 file, at the very top:
114 <pre>
115 TraceLog /path/to/ftpd/trace.log
116 Trace DEFAULT:10
117 </pre>
118 Then <b>all</b> of the above channels, up to log level 10, will have their
119 messages logged.
120
121 <p>
122 If you want to look at the default trace channels <i>except</i> for a
123 particular channel, use level 0 to effectively disable that channel.
124 For example, to exclude the "fsio" channel but see the rest of the default
125 channels, you would use:
126 <pre>
127 Trace DEFAULT:10 fsio:0
128 </pre>
129
130 <p>
131 Note that there are trace channel names that are <b>not</b> part of the
132 "DEFAULT" channel name list (<i>e.g.</i> "class"); any custom channel names,
133 such as might be used by a third-party module, are also not covered in the
134 "DEFAULT" list. For example, the <code>mod_tls</code> module may log to a
135 "tls" channel. Any messages to that "tls" channel would not appear in the
136 <code>TraceLog</code> file, using the above configuration. Instead,
137 you would need to explicitly mention the "tls" channel, <i>i.e.</i>:
138 <pre>
139 TraceLog /path/to/ftpd/trace.log
140 Trace DEFAULT:10 tls:10
141 </pre>
142
143 <p>
144 <b>Optional Trace Log Channels</b><br>
145 In addition to the default trace log channels listed above, there are
146 optional trace log channels:
147 <ul>
148 <li><code>directory</code>
149 <p>
150 The "directory" log channel is used when the core engine attempts
151 to find the closest matching <code>&lt;Directory&gt;</code> section
152 for a path.
153 </li>
154
155 <p>
156 <li><code>fileperms</code>
157 <p>
158 The "fileperms" log channel is used whenever a user action involving
159 the filesystem (<i>e.g.</i> opening/closing/writing/renaming/deleting
160 files or directories) fails. This channel will log the relevant FTP
161 command, user name, UID/GID, filesystem path, and the error.
162 </li>
163 </ul>
164
165 <p>
166 <b>Trace Log Format</b><br>
167 Every log message in a <code>TraceLog</code> uses the following format:
168 <pre>
169 <i>timestamp [process ID] &lt;channel:level&gt;: message</i>
170 </pre>
171 For example:
172 <pre>
173 Jan 16 17:15:58 [30583] &lt;auth:6&gt;: dispatching auth request "endgrent" to module mod_auth_unix
174 </pre>
175 This shows process ID 30583 logging to the "auth" channel, log level 6, a
176 message about handling the "endgrent" Auth API request.
177
178 <p><a name="RuntimeTuning">
179 <b>Runtime Tracing</b><br>
180 If Controls support is enabled in your <code>proftpd</code>, <i>and</i>
181 you are using the <code>mod_ctrls_admin</code> module, then you can also use the
182 <code>ftpdctl</code> command to adjust the trace logging settings in the
183 running <code>proftpd</code>, without needing to change your
184 <code>proftpd.conf</code> file. See:
185 <pre>
186 <a href="../contrib/mod_ctrls_admin.html#trace">doc/contrib/mod_ctrls_admin.html#trace</a>
187 </pre>
188 for more information on the <code>ftpdctl trace</code> action.
189
190 <p>
191 Here's a concrete example of how tuning the trace logging at runtime can be
192 useful. You may need the extra information logged via trace logging in order
193 to track down/debug some issue, <b>but</b> you do not want to enable trace
194 logging all of the time in your environment. Fortunately, it is possible
195 to make it possible to get the trace logging information you need, when
196 you need to get it, and then turn the trace logging off <i>all without
197 restarting proftpd</i>.
198
199 <p>
200 First, you need to configure your <code>proftpd.conf</code> like so:
201 <pre>
202 TraceLog /path/to/proftpd/trace.log
203 Trace DEFAULT:0
204 </pre>
205 This configuration tells proftpd to direct all trace logging to that
206 <code>TraceLog</code> file, <i>but</i> to not actually write anything to the
207 file; the log level zero (0) filters out all trace logging messages. Start
208 proftpd with the updated <code>proftpd.conf</code>. Later, while proftpd is
209 running, you can tune the tracing using the
210 <a href="Controls.html"><code>ftpdctl</code></a> utility, like this:
211 <pre>
212 $ ftpdctl trace lock:10 scoreboard:5
213 </pre>
214 which dynamically changes the 'lock' trace channel level to 10, and the
215 'scoreboard' trace channel level to 5. Once you have gathered the necessary
216 information in the <code>TraceLog</code> file, you then use <code>ftpdctl</code>
217 again and restore the trace levels back to zero, effectively turning off
218 trace logging once more:
219 <pre>
220 $ ftpdctl trace DEFAULT:0
221 </pre>
222 Note that the changed settings will only apply to <b>new</b> sessions; this
223 does <b>not</b> change the trace logging for <i>existing</i> sessions.
224
225 <p>
226 <b>Use Only When Needed</b><br>
227 Remember that tracing is a <i>verbose</i> (and thus expensive) form of logging,
228 and thus makes the <code>proftpd</code> daemon run slower. Tracing should only
229 ever be used for debugging and development purposes; once your
230 <code>proftpd</code> is up and running the way you need, you should remove all
231 <code>Trace</code> and <code>TraceLog</code> directives from your
232 <code>proftpd.conf</code>.
233
234 <p><a name="FAQ">
235 <b>Frequently Asked Questions</b><br>
236
237 <p>
238 <font color=red>Question</font>: Can I configure <code>Trace</code> on a
239 per-user basis, using <code>mod_ifsession</code>'s <code>&lt;IfUser&gt;</code>?<br>
240 <font color=blue>Answer</font>: You can indeed use <code>mod_ifsession</code>
241 for <code>Trace</code> configurations, starting in ProFTPD 1.3.4rc1. To
242 do this, you need to use the optional "session" keyword in your
243 <code>Trace</code> configuration, <i>e.g.</i>:
244 <pre>
245 &lt;IfUser <i>traced-user</i>&gt;
246 Trace session DEFAULT:10
247 &lt;/IfUser&gt;
248 </pre>
249 This goes for <code>&lt;IfClass&gt;</code> and <code>&lt;IfGroup&gt;</code>
250 sections as well.
251
252 <p>
253 <hr>
254 <font size=2><b><i>
255 &copy; Copyright 2017 The ProFTPD Project<br>
256 All Rights Reserved<br>
257 </i></b></font>
258 <hr>
259
260 </body>
261 </html>