151097726790a2c5b57aed09cbe8681b742631c2
[yaz-moved-to-github.git] / doc / yaz-log-man.xml
1 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook V4.1//EN"
2  "http://www.oasis-open.org/docbook/xml/4.1/docbookx.dtd"
3
4      <!ENTITY % local SYSTEM "local.ent">
5      %local;
6      <!ENTITY % entities SYSTEM "entities.ent">
7      %entities;
8      <!ENTITY % idcommon SYSTEM "common/common.ent">
9      %idcommon;
10 ]>
11 <refentry id="yaz-log">
12  <refentryinfo>
13   <productname>YAZ</productname>
14   <productnumber>&version;</productnumber>
15  </refentryinfo>
16  
17  <refmeta>
18   <refentrytitle>yaz-log</refentrytitle>
19   <manvolnum>7</manvolnum>
20  </refmeta>
21  
22  <refnamediv>
23   <refname>yaz-log</refname>
24   <refpurpose>Log handling in all yaz-based programs</refpurpose>
25  </refnamediv>
26  
27  <refsynopsisdiv>
28   <cmdsynopsis>
29    <command>yaz-XXXX</command>
30    <arg choice="opt"><option>-v <replaceable>loglevel,...</replaceable></option></arg>
31    <arg choice="opt"><option>-l <replaceable>logfile</replaceable></option></arg>
32   </cmdsynopsis>
33  </refsynopsisdiv>
34  
35  <refsect1><title>DESCRIPTION</title>
36   <para>
37    All YAZ-based programs use a common log subsystem, and should support
38    common command line options for controlling it. This man page documents
39    those.
40   </para>
41   <para>
42   </para>
43  </refsect1>
44  
45  <refsect1><title>OPTIONS</title>
46   
47   <variablelist>
48    <varlistentry>
49     <term>-l<replaceable> logfile</replaceable></term>
50     <listitem>
51      <para>
52       Specify the file where the log is to be written. If none is specified,
53       <filename>stderr</filename> is used. The log is appended to this file.
54       If the file grows overly large, it is silently rotated: It is renamed to
55       <replaceable>logfile</replaceable>.1,
56       <replaceable>logfile</replaceable>.2, .., 9 
57       (old such file is deleted), and a
58       new file is opened. The limit defaults to 1GB, but can be set by the
59       program.
60       The rotating limit can be specified with option <literal>-r</literal>
61       for the YAZ frontend server (yaz-ztest).
62      </para>
63      <para>
64       Rotation can also be implicitly enabled by using a filename
65       which gets changed for a given date, due to substitutions as
66       given by the strftime(3) function.
67      </para>
68     </listitem>
69    </varlistentry>
70
71    <varlistentry>
72     <term>-v<replaceable> loglevel</replaceable></term>
73     <listitem><para>
74       Specify the logging level. The argument is a set of log level names,
75       separated by commas (no whitespace!), optionally preceded by a '-' to
76       negate that level. Most programs have their own default, often
77       containing <literal>fatal,warn,log</literal>, and some
78       application-specific values. The default list can be cleared with the
79       word <literal>none</literal>, or individual bits can be removed by
80       prefixing them with a dash '-'.
81      </para></listitem>
82    </varlistentry>
83
84   </variablelist>
85  </refsect1>
86
87  <refsect1><title>LOG LEVELS TO CONTROL LOGGING</title>
88   <para>
89    Some of the log levels control the way the log is written. 
90   </para>
91   <para>
92    <literal>flush</literal> causes the log to be flushed after every write.
93    This can have serious implications to performance, and should not be used
94    in production. On the other hand, when debugging a program crash, this can
95    be extremely useful. The option <literal>debug</literal> implies
96    <literal>flush</literal> as well.
97   </para>
98   <para>
99    <literal>notime</literal> prevents the writing of time stamps. This is
100    intended for automatic test scripts, which should produce predictable log
101    files that are easy to compare.
102   </para>
103   
104  </refsect1> 
105
106  <refsect1><title>GENERAL LOG LEVELS IN YAZ ITSELF</title>
107   <para>
108    YAZ itself uses the following log levels:
109   </para>
110   <para>
111    <literal>fatal</literal> for fatal errors, that prevent further execution
112    of the program.
113   </para>
114   <para>
115    <literal>warn</literal> for warnings about things that should be corrected.
116   </para>
117   <para>
118    <literal>debug</literal> for debugging. This flag may be used temporarily
119    when developing or debugging yaz, or a program that uses yaz. It is
120    practically deprecated, you should be defining and using your own log
121    levels (see below).
122   </para>
123   <para>
124    <literal>all</literal> turns on almost all hard-coded log levels. 
125   </para>
126   <para>
127    <literal>loglevel</literal> logs information about the log levels used by
128    the program. Every time the log level is changed, lists all bits that are
129    on. Every time a module asks for its log bits, this is logged. This can be
130    used for getting an idea of what log levels are available in any program
131    that uses yaz-log. Start the program with <literal>-v
132    none,loglevel</literal>, and do some common operations with it. Another way
133    is to grep for <function>yaz_log_module_level</function> in the source
134    code, as in
135    <screen>
136       find . -name '*.[ch]' -print | 
137          xargs grep yaz_log_module_level | 
138          grep '"' |
139          cut -d'"' -f2 | 
140          sort -u   
141    </screen>
142   </para>
143   <para>
144    <literal>eventl</literal>, <literal>malloc</literal>, 
145    <literal>nmem</literal>, <literal>odr</literal> are used internally for
146    debugging yaz.
147   </para>
148   <para>
149   </para>
150  </refsect1> 
151
152  <refsect1><title>LOG LEVELS FOR CLIENTS</title>
153   <para>
154    <literal>zoom</literal> logs the calls to the zoom API, which may be useful
155    in debugging client applications.
156   </para>
157  </refsect1> 
158
159  <refsect1><title>LOG LEVELS FOR SERVERS</title>
160   <para>
161    <literal>server</literal> logs the server functions on a high level,
162    starting up, listening on a port, etc.
163   </para>
164   <para>
165    <literal>session</literal> logs individual sessions (connections).
166   </para>
167   <para>
168    <literal>request</literal> logs a one-liner for each request (init, search,
169    etc).
170   </para>
171   <para>
172    <literal>requestdetail</literal> logs the details of every request, before
173    it is passed to the back-end, and the results received from it.
174   </para>
175   <para>
176    Each server program (zebra, etc) is supposed to define its own log levels
177    in addition to these. As they depend on the server in question, they can
178    not be described here. See above how to find out about them.
179   </para>
180  </refsect1>
181
182  <refsect1><title>LOGGING EXAMPLES</title>
183   <para>
184    See what log levels yaz-ztest is using:
185    <screen>
186     yaz-ztest -1 -v none,loglevel
187     14:43:29-23/11 [loglevel] Setting log level to 4096 = 0x00001000
188     14:43:29-23/11 [loglevel] Static  log bit 00000001 'fatal' is off
189     14:43:29-23/11 [loglevel] Static  log bit 00000002 'debug' is off
190     14:43:29-23/11 [loglevel] Static  log bit 00000004 'warn' is off
191     14:43:29-23/11 [loglevel] Static  log bit 00000008 'log' is off
192     14:43:29-23/11 [loglevel] Static  log bit 00000080 'malloc' is off
193     14:43:29-23/11 [loglevel] Static  log bit 00000800 'flush' is off
194     14:43:29-23/11 [loglevel] Static  log bit 00001000 'loglevel' is ON
195     14:43:29-23/11 [loglevel] Static  log bit 00002000 'server' is off
196     14:43:29-23/11 [loglevel] Dynamic log bit 00004000 'session' is off
197     14:43:29-23/11 [loglevel] Dynamic log bit 00008000 'request' is off
198     14:44:13-23/11 yaz-ztest [loglevel] returning log bit 0x4000 for 'session'
199     14:44:13-23/11 yaz-ztest [loglevel] returning log bit 0x2000 for 'server'
200     14:44:13-23/11 yaz-ztest [loglevel] returning NO log bit for 'eventl'
201     14:44:20-23/11 yaz-ztest [loglevel] returning log bit 0x4000 for 'session'
202     14:44:20-23/11 yaz-ztest [loglevel] returning log bit 0x8000 for 'request'
203     14:44:20-23/11 yaz-ztest [loglevel] returning NO log bit for 'requestdetail'
204     14:44:20-23/11 yaz-ztest [loglevel] returning NO log bit for 'odr'
205     14:44:20-23/11 yaz-ztest [loglevel] returning NO log bit for 'ztest'
206    </screen>
207   </para>
208   <para>
209    See the details of the requests for yaz-ztest
210    <screen>
211    ./yaz-ztest -1 -v requestdetail
212    14:45:35-23/11 yaz-ztest [server] Adding static Z3950 listener on tcp:@:9999
213    14:45:35-23/11 yaz-ztest [server] Starting server ./yaz-ztest pid=32200
214    14:45:38-23/11 yaz-ztest [session] Starting session from tcp:127.0.0.1 (pid=32200)
215    14:45:38-23/11 yaz-ztest [requestdetail] Got initRequest
216    14:45:38-23/11 yaz-ztest [requestdetail] Id:        81
217    14:45:38-23/11 yaz-ztest [requestdetail] Name:      YAZ
218    14:45:38-23/11 yaz-ztest [requestdetail] Version:   2.0.28
219    14:45:38-23/11 yaz-ztest [requestdetail] Negotiated to v3: srch prst del extendedServices namedresults scan sort
220    14:45:38-23/11 yaz-ztest [request] Init from 'YAZ' (81) (ver 2.0.28) OK
221    14:45:39-23/11 yaz-ztest [requestdetail] Got SearchRequest.
222    14:45:39-23/11 yaz-ztest [requestdetail] ResultSet '1'
223    14:45:39-23/11 yaz-ztest [requestdetail] Database 'Default'
224    14:45:39-23/11 yaz-ztest [requestdetail] RPN query. Type: Bib-1
225    14:45:39-23/11 yaz-ztest [requestdetail]  term 'foo' (general)
226    14:45:39-23/11 yaz-ztest [requestdetail] resultCount: 7
227    14:45:39-23/11 yaz-ztest [request] Search Z: @attrset Bib-1 foo  OK:7 hits
228    14:45:41-23/11 yaz-ztest [requestdetail] Got PresentRequest.
229    14:45:41-23/11 yaz-ztest [requestdetail] Request to pack 1+1 1
230    14:45:41-23/11 yaz-ztest [requestdetail] pms=1048576, mrs=1048576
231    14:45:41-23/11 yaz-ztest [request] Present: [1] 1+1  OK 1 records returned
232    </screen> 
233   </para>
234  </refsect1> 
235
236  <refsect1><title>LOG FILENAME EXAMPLES</title>
237   <para>
238    A file with format my_YYYYMMDD.log is where Y, M, D is year, month, and day
239    digits is given as follows
240    <literal>-l my_%Y%m%d.log</literal> . And since the filename
241    is depending on day, rotaion will occur on midnight.
242   </para>
243   <para>
244    A weekly log could be specified as 
245    <literal>-l my_%Y%U.log</literal>.
246   </para>
247  </refsect1>
248   
249  <refsect1><title>FILES</title>
250   <para>
251    <filename><replaceable>prefix</replaceable>/include/yaz/log.h</filename>
252    <filename><replaceable>prefix</replaceable>/src/log.c</filename>
253   </para>
254  </refsect1>
255  <refsect1><title>SEE ALSO</title>
256   <para>
257    <citerefentry>
258     <refentrytitle>yaz</refentrytitle>
259     <manvolnum>7</manvolnum>
260    </citerefentry>
261
262    <citerefentry>
263     <refentrytitle>yaz-ztest</refentrytitle>
264     <manvolnum>8</manvolnum>
265    </citerefentry>
266
267    <citerefentry>
268     <refentrytitle>yaz-client</refentrytitle>
269     <manvolnum>1</manvolnum>
270    </citerefentry>
271
272    <citerefentry>
273     <refentrytitle>strftime</refentrytitle>
274     <manvolnum>3</manvolnum>
275    </citerefentry>
276   </para>
277  </refsect1>
278 </refentry>
279
280 <!-- Keep this comment at the end of the file
281 Local variables:
282 mode: sgml
283 sgml-omittag:t
284 sgml-shorttag:t
285 sgml-minimize-attributes:nil
286 sgml-always-quote-attributes:t
287 sgml-indent-step:1
288 sgml-indent-data:t
289 sgml-parent-document:nil
290 sgml-local-catalogs: nil
291 sgml-namecase-general:t
292 End:
293 -->