1 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook V4.1//EN"
2 "http://www.oasis-open.org/docbook/xml/4.1/docbookx.dtd"
4 <!ENTITY % local SYSTEM "local.ent">
6 <!ENTITY % entities SYSTEM "entities.ent">
8 <!ENTITY % idcommon SYSTEM "common/common.ent">
11 <!-- $Id: yaz-log-man.xml,v 1.8 2007-05-22 11:10:08 adam Exp $ -->
12 <refentry id="yaz-log">
14 <productname>YAZ</productname>
15 <productnumber>&version;</productnumber>
19 <refentrytitle>yaz-log</refentrytitle>
20 <manvolnum>7</manvolnum>
24 <refname>yaz-log</refname>
25 <refpurpose>Log handling in all yaz-based programs</refpurpose>
30 <command>yaz-XXXX</command>
31 <arg choice="opt"><option>-v <replaceable>loglevel,...</replaceable></option></arg>
32 <arg choice="opt"><option>-l <replaceable>logfile</replaceable></option></arg>
36 <refsect1><title>DESCRIPTION</title>
38 All YAZ-based programs use a common log subsystem, and should support
39 common command line options for controlling it. This man page documents
46 <refsect1><title>OPTIONS</title>
50 <term>-l<replaceable> logfile</replaceable></term>
53 Specify the file where the log is to be written. If none is specified,
54 <filename>stderr</filename> is used. The log is appended to this file.
55 If the file grows overly large, it is silently rotated: It is renamed to
56 <replaceable>logfile</replaceable>.1,
57 <replaceable>logfile</replaceable>.2, .., 9
58 (old such file is deleted), and a
59 new file is opened. The limit defaults to 1GB, but can be set by the
61 The rotating limit can be specified with option <literal>-r</literal>
62 for the YAZ frontend server (yaz-ztest).
65 Rotation can also be implicitly enabled by using a filename
66 which gets changed for a given date, due to substitutions as
67 given by the strftime(3) function.
73 <term>-v<replaceable> loglevel</replaceable></term>
75 Specify the logging level. The argument is a set of log level names,
76 separated by commas (no whitespace!), optionally preceded by a '-' to
77 negate that level. Most programs have their own default, often
78 containing <literal>fatal,warn,log</literal>, and some
79 application-specific values. The default list can be cleared with the
80 word <literal>none</literal>, or individual bits can be removed by
81 prefixing them with a dash '-'.
88 <refsect1><title>LOG LEVELS TO CONTROL LOGGING</title>
90 Some of the log levels control the way the log is written.
93 <literal>flush</literal> causes the log to be flushed after every write.
94 This can have serious implications to performance, and should not be used
95 in production. On the other hand, when debugging a program crash, this can
96 be extremely useful. The option <literal>debug</literal> implies
97 <literal>flush</literal> as well.
100 <literal>notime</literal> prevents the writing of time stamps. This is
101 intended for automatic test scripts, which should produce predictable log
102 files that are easy to compare.
107 <refsect1><title>GENERAL LOG LEVELS IN YAZ ITSELF</title>
109 YAZ itself uses the following log levels:
112 <literal>fatal</literal> for fatal errors, that prevent further execution
116 <literal>warn</literal> for warnings about things that should be corrected.
119 <literal>debug</literal> for debugging. This flag may be used temporarily
120 when developing or debugging yaz, or a program that uses yaz. It is
121 practically deprecated, you should be defining and using your own log
125 <literal>all</literal> turns on almost all hard-coded log levels.
128 <literal>loglevel</literal> logs information about the log levels used by
129 the program. Every time the log level is changed, lists all bits that are
130 on. Every time a module asks for its log bits, this is logged. This can be
131 used for getting an idea of what log levels are available in any program
132 that uses yaz-log. Start the program with <literal>-v
133 none,loglevel</literal>, and do some common operations with it. Another way
134 is to grep for <function>yaz_log_module_level</function> in the source
137 find . -name '*.[ch]' -print |
138 xargs grep yaz_log_module_level |
145 <literal>eventl</literal>, <literal>malloc</literal>,
146 <literal>nmem</literal>, <literal>odr</literal> are used internally for
153 <refsect1><title>LOG LEVELS FOR CLIENTS</title>
155 <literal>zoom</literal> logs the calls to the zoom API, which may be useful
156 in debugging client applications.
160 <refsect1><title>LOG LEVELS FOR SERVERS</title>
162 <literal>server</literal> logs the server functions on a high level,
163 starting up, listening on a port, etc.
166 <literal>session</literal> logs individual sessions (connections).
169 <literal>request</literal> logs a one-liner for each request (init, search,
173 <literal>requestdetail</literal> logs the details of every request, before
174 it is passed to the back-end, and the results received from it.
177 Each server program (zebra, etc) is supposed to define its own log levels
178 in addition to these. As they depend on the server in question, they can
179 not be described here. See above how to find out about them.
183 <refsect1><title>LOGGING EXAMPLES</title>
185 See what log levels yaz-ztest is using:
187 yaz-ztest -1 -v none,loglevel
188 14:43:29-23/11 [loglevel] Setting log level to 4096 = 0x00001000
189 14:43:29-23/11 [loglevel] Static log bit 00000001 'fatal' is off
190 14:43:29-23/11 [loglevel] Static log bit 00000002 'debug' is off
191 14:43:29-23/11 [loglevel] Static log bit 00000004 'warn' is off
192 14:43:29-23/11 [loglevel] Static log bit 00000008 'log' is off
193 14:43:29-23/11 [loglevel] Static log bit 00000080 'malloc' is off
194 14:43:29-23/11 [loglevel] Static log bit 00000800 'flush' is off
195 14:43:29-23/11 [loglevel] Static log bit 00001000 'loglevel' is ON
196 14:43:29-23/11 [loglevel] Static log bit 00002000 'server' is off
197 14:43:29-23/11 [loglevel] Dynamic log bit 00004000 'session' is off
198 14:43:29-23/11 [loglevel] Dynamic log bit 00008000 'request' is off
199 14:44:13-23/11 yaz-ztest [loglevel] returning log bit 0x4000 for 'session'
200 14:44:13-23/11 yaz-ztest [loglevel] returning log bit 0x2000 for 'server'
201 14:44:13-23/11 yaz-ztest [loglevel] returning NO log bit for 'eventl'
202 14:44:20-23/11 yaz-ztest [loglevel] returning log bit 0x4000 for 'session'
203 14:44:20-23/11 yaz-ztest [loglevel] returning log bit 0x8000 for 'request'
204 14:44:20-23/11 yaz-ztest [loglevel] returning NO log bit for 'requestdetail'
205 14:44:20-23/11 yaz-ztest [loglevel] returning NO log bit for 'odr'
206 14:44:20-23/11 yaz-ztest [loglevel] returning NO log bit for 'ztest'
210 See the details of the requests for yaz-ztest
212 ./yaz-ztest -1 -v requestdetail
213 14:45:35-23/11 yaz-ztest [server] Adding static Z3950 listener on tcp:@:9999
214 14:45:35-23/11 yaz-ztest [server] Starting server ./yaz-ztest pid=32200
215 14:45:38-23/11 yaz-ztest [session] Starting session from tcp:127.0.0.1 (pid=32200)
216 14:45:38-23/11 yaz-ztest [requestdetail] Got initRequest
217 14:45:38-23/11 yaz-ztest [requestdetail] Id: 81
218 14:45:38-23/11 yaz-ztest [requestdetail] Name: YAZ
219 14:45:38-23/11 yaz-ztest [requestdetail] Version: 2.0.28
220 14:45:38-23/11 yaz-ztest [requestdetail] Negotiated to v3: srch prst del extendedServices namedresults scan sort
221 14:45:38-23/11 yaz-ztest [request] Init from 'YAZ' (81) (ver 2.0.28) OK
222 14:45:39-23/11 yaz-ztest [requestdetail] Got SearchRequest.
223 14:45:39-23/11 yaz-ztest [requestdetail] ResultSet '1'
224 14:45:39-23/11 yaz-ztest [requestdetail] Database 'Default'
225 14:45:39-23/11 yaz-ztest [requestdetail] RPN query. Type: Bib-1
226 14:45:39-23/11 yaz-ztest [requestdetail] term 'foo' (general)
227 14:45:39-23/11 yaz-ztest [requestdetail] resultCount: 7
228 14:45:39-23/11 yaz-ztest [request] Search Z: @attrset Bib-1 foo OK:7 hits
229 14:45:41-23/11 yaz-ztest [requestdetail] Got PresentRequest.
230 14:45:41-23/11 yaz-ztest [requestdetail] Request to pack 1+1 1
231 14:45:41-23/11 yaz-ztest [requestdetail] pms=1048576, mrs=1048576
232 14:45:41-23/11 yaz-ztest [request] Present: [1] 1+1 OK 1 records returned
237 <refsect1><title>LOG FILENAME EXAMPLES</title>
239 A file with format my_YYYYMMDD.log is where Y, M, D is year, month, and day
240 digits is given as follows
241 <literal>-l my_%Y%m%d.log</literal> . And since the filename
242 is depending on day, rotaion will occur on midnight.
245 A weekly log could be specified as
246 <literal>-l my_%Y%U.log</literal>.
250 <refsect1><title>FILES</title>
252 <filename><replaceable>prefix</replaceable>/include/yaz/log.h</filename>
253 <filename><replaceable>prefix</replaceable>/src/log.c</filename>
256 <refsect1><title>SEE ALSO</title>
259 <refentrytitle>yaz</refentrytitle>
260 <manvolnum>7</manvolnum>
264 <refentrytitle>yaz-ztest</refentrytitle>
265 <manvolnum>8</manvolnum>
269 <refentrytitle>yaz-client</refentrytitle>
270 <manvolnum>1</manvolnum>
274 <refentrytitle>strftime</refentrytitle>
275 <manvolnum>3</manvolnum>
281 <!-- Keep this comment at the end of the file
286 sgml-minimize-attributes:nil
287 sgml-always-quote-attributes:t
290 sgml-parent-document:nil
291 sgml-local-catalogs: nil
292 sgml-namecase-general:t