corrected DOCTYPE header and called emacs nxml-mode instead of sgml-mode in bottom...
[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 <!-- $Id: yaz-log-man.xml,v 1.3 2006-04-24 12:41:00 marc Exp $ -->
5 <refentry id="yaz-log">
6  <refmeta>
7   <refentrytitle>yaz-log</refentrytitle>
8   <manvolnum>7</manvolnum>
9  </refmeta>
10  
11  <refnamediv>
12   <refname>yaz-log</refname>
13   <refpurpose>Log handling in all yaz-based programs</refpurpose>
14  </refnamediv>
15  
16  <refsynopsisdiv>
17   <cmdsynopsis>
18    <command>yaz-XXXX</command>
19    <arg choice="opt"><option>-v <replaceable>loglevel,...</replaceable></option></arg>
20    <arg choice="opt"><option>-l <replaceable>logfile</replaceable></option></arg>
21   </cmdsynopsis>
22  </refsynopsisdiv>
23  
24  <refsect1><title>DESCRIPTION</title>
25   <para>
26    All YAZ-based programs use a common log subsystem, and should support
27    common command line options for controlling it. This man page documents
28    those.
29   </para>
30   <para>
31   </para>
32  </refsect1>
33  
34  <refsect1><title>OPTIONS</title>
35   
36   <variablelist>
37    <varlistentry>
38     <term>-l<replaceable> logfile</replaceable></term>
39     <listitem><para>
40       Specify the file where the log is to be written. If none is specified,
41       <filename>stderr</filename> is used. The log is appended to this file.
42       If the file grows overly large, it is silently rotated: It is renamed to
43       <replaceable>logfile</replaceable>.1 (old such file is deleted), and a
44       new file is opened. The limit defaults to 1GB, but can be set by the
45       program.
46     </para></listitem>
47    </varlistentry>
48
49    <varlistentry>
50     <term>-v<replaceable> loglevel</replaceable></term>
51     <listitem><para>
52       Specify the logging level. The argument is a set of log level names,
53       separated by commas (no whitespace!), optionally preceded by a '-' to
54       negate that level. Most programs have their own default, often
55       containing <literal>fatal,warn,log</literal>, and some
56       application-specific values. The default list can be cleared with the
57       word <literal>none</literal>, or individual bits can be removed by
58       prefixing them with a dash '-'.
59      </para></listitem>
60    </varlistentry>
61
62   </variablelist>
63  </refsect1>
64
65  <refsect1><title>LOG LEVELS TO CONTROL LOGGING</title>
66   <para>
67    Some of the log levels control the way the log is written. 
68   </para>
69   <para>
70    <literal>flush</literal> causes the log to be flushed after every write.
71    This can have serious implications to performance, and should not be used
72    in production. On the other hand, when debugging a program crash, this can
73    be extremely useful. The option <literal>debug</literal> implies
74    <literal>flush</literal> as well.
75   </para>
76   <para>
77    <literal>notime</literal> prevents the writing of time stamps. This is
78    intended for automatic test scripts, which should produce predictable log
79    files that are easy to compare.
80   </para>
81   
82  </refsect1> 
83
84  <refsect1><title>GENERAL LOG LEVELS IN YAZ ITSELF</title>
85   <para>
86    YAZ itself uses the following log levels:
87   </para>
88   <para>
89    <literal>fatal</literal> for fatal errors, that prevent further execution
90    of the program.
91   </para>
92   <para>
93    <literal>warn</literal> for warnings about things that should be corrected.
94   </para>
95   <para>
96    <literal>debug</literal> for debugging. This flag may be used temporarily
97    when developing or debugging yaz, or a program that uses yaz. It is
98    practically deprecated, you should be defining and using your own log
99    levels (see below).
100   </para>
101   <para>
102    <literal>all</literal> turns on almost all hard-coded log levels. 
103   </para>
104   <para>
105    <literal>loglevel</literal> logs information about the log levels used by
106    the program. Every time the log level is changed, lists all bits that are
107    on. Every time a module asks for its log bits, this is logged. This can be
108    used for getting an idea of what log levels are available in any program
109    that uses yaz-log. Start the program with <literal>-v
110    none,loglevel</literal>, and do some common operations with it. Another way
111    is to grep for <function>yaz_log_module_level</function> in the source
112    code, as in
113    <screen>
114       find . -name '*.[ch]' -print | 
115          xargs grep yaz_log_module_level | 
116          grep '"' |
117          cut -d'"' -f2 | 
118          sort -u   
119    </screen>
120   </para>
121   <para>
122    <literal>eventl</literal>, <literal>malloc</literal>, 
123    <literal>nmem</literal>, <literal>odr</literal> are used internally for
124    debugging yaz.
125   </para>
126   <para>
127   </para>
128  </refsect1> 
129
130  <refsect1><title>LOG LEVELS FOR CLIENTS</title>
131   <para>
132    <literal>zoom</literal> logs the calls to the zoom API, which may be useful
133    in debugging client applications.
134   </para>
135  </refsect1> 
136
137  <refsect1><title>LOG LEVELS FOR SERVERS</title>
138   <para>
139    <literal>server</literal> logs the server functions on a high level,
140    starting up, listening on a port, etc.
141   </para>
142   <para>
143    <literal>session</literal> logs individual sessions (connections).
144   </para>
145   <para>
146    <literal>request</literal> logs a one-liner for each request (init, search,
147    etc).
148   </para>
149   <para>
150    <literal>requestdetail</literal> logs the details of every request, before
151    it is passed to the back-end, and the results received from it.
152   </para>
153   <para>
154    Each server program (zebra, etc) is supposed to define its own log levels
155    in addition to these. As they depend on the server in question, they can
156    not be described here. See above how to find out about them.
157   </para>
158  </refsect1> 
159
160  <refsect1><title>EXAMPLES</title>
161   <para>
162    See what log levels yaz-ztest is using:
163    <screen>
164     yaz-ztest -1 -v none,loglevel
165     14:43:29-23/11 [loglevel] Setting log level to 4096 = 0x00001000
166     14:43:29-23/11 [loglevel] Static  log bit 00000001 'fatal' is off
167     14:43:29-23/11 [loglevel] Static  log bit 00000002 'debug' is off
168     14:43:29-23/11 [loglevel] Static  log bit 00000004 'warn' is off
169     14:43:29-23/11 [loglevel] Static  log bit 00000008 'log' is off
170     14:43:29-23/11 [loglevel] Static  log bit 00000080 'malloc' is off
171     14:43:29-23/11 [loglevel] Static  log bit 00000800 'flush' is off
172     14:43:29-23/11 [loglevel] Static  log bit 00001000 'loglevel' is ON
173     14:43:29-23/11 [loglevel] Static  log bit 00002000 'server' is off
174     14:43:29-23/11 [loglevel] Dynamic log bit 00004000 'session' is off
175     14:43:29-23/11 [loglevel] Dynamic log bit 00008000 'request' is off
176     14:44:13-23/11 yaz-ztest [loglevel] returning log bit 0x4000 for 'session'
177     14:44:13-23/11 yaz-ztest [loglevel] returning log bit 0x2000 for 'server'
178     14:44:13-23/11 yaz-ztest [loglevel] returning NO log bit for 'eventl'
179     14:44:20-23/11 yaz-ztest [loglevel] returning log bit 0x4000 for 'session'
180     14:44:20-23/11 yaz-ztest [loglevel] returning log bit 0x8000 for 'request'
181     14:44:20-23/11 yaz-ztest [loglevel] returning NO log bit for 'requestdetail'
182     14:44:20-23/11 yaz-ztest [loglevel] returning NO log bit for 'odr'
183     14:44:20-23/11 yaz-ztest [loglevel] returning NO log bit for 'ztest'
184    </screen>
185   </para>
186   <para>
187    See the details of the requests for yaz-ztest
188    <screen>
189    ./yaz-ztest -1 -v requestdetail
190    14:45:35-23/11 yaz-ztest [server] Adding static Z3950 listener on tcp:@:9999
191    14:45:35-23/11 yaz-ztest [server] Starting server ./yaz-ztest pid=32200
192    14:45:38-23/11 yaz-ztest [session] Starting session from tcp:127.0.0.1 (pid=32200)
193    14:45:38-23/11 yaz-ztest [requestdetail] Got initRequest
194    14:45:38-23/11 yaz-ztest [requestdetail] Id:        81
195    14:45:38-23/11 yaz-ztest [requestdetail] Name:      YAZ
196    14:45:38-23/11 yaz-ztest [requestdetail] Version:   2.0.28
197    14:45:38-23/11 yaz-ztest [requestdetail] Negotiated to v3: srch prst del extendedServices namedresults scan sort
198    14:45:38-23/11 yaz-ztest [request] Init from 'YAZ' (81) (ver 2.0.28) OK
199    14:45:39-23/11 yaz-ztest [requestdetail] Got SearchRequest.
200    14:45:39-23/11 yaz-ztest [requestdetail] ResultSet '1'
201    14:45:39-23/11 yaz-ztest [requestdetail] Database 'Default'
202    14:45:39-23/11 yaz-ztest [requestdetail] RPN query. Type: Bib-1
203    14:45:39-23/11 yaz-ztest [requestdetail]  term 'foo' (general)
204    14:45:39-23/11 yaz-ztest [requestdetail] resultCount: 7
205    14:45:39-23/11 yaz-ztest [request] Search Z: @attrset Bib-1 foo  OK:7 hits
206    14:45:41-23/11 yaz-ztest [requestdetail] Got PresentRequest.
207    14:45:41-23/11 yaz-ztest [requestdetail] Request to pack 1+1 1
208    14:45:41-23/11 yaz-ztest [requestdetail] pms=1048576, mrs=1048576
209    14:45:41-23/11 yaz-ztest [request] Present: [1] 1+1  OK 1 records returned
210    </screen> 
211   </para>
212  </refsect1> 
213
214  <refsect1><title>FILES</title>
215   <para>
216    <filename><replaceable>prefix</replaceable>/include/yaz/log.h</filename>
217    <filename><replaceable>prefix</replaceable>/src/log.c</filename>
218   </para>
219  </refsect1>
220  <refsect1><title>SEE ALSO</title>
221   <para>
222    yaz(7)
223    yaz-ztest(8) yaz-client(1) 
224   </para>
225  </refsect1>
226 </refentry>
227
228 <!-- Keep this Emacs mode comment at the end of the file
229 Local variables:
230 mode: nxml
231 End:
232 -->
233