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 <refentry id="yaz-log">
13 <productname>YAZ</productname>
14 <productnumber>&version;</productnumber>
18 <refentrytitle>yaz-log</refentrytitle>
19 <manvolnum>7</manvolnum>
23 <refname>yaz-log</refname>
24 <refpurpose>Log handling in all yaz-based programs</refpurpose>
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>
35 <refsect1><title>DESCRIPTION</title>
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
45 <refsect1><title>OPTIONS</title>
49 <term>-l<replaceable> logfile</replaceable></term>
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
60 The rotating limit can be specified with option <literal>-r</literal>
61 for the YAZ frontend server (yaz-ztest).
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.
72 <term>-v<replaceable> loglevel</replaceable></term>
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 '-'.
87 <refsect1><title>LOG LEVELS TO CONTROL LOGGING</title>
89 Some of the log levels control the way the log is written.
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.
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.
106 <refsect1><title>GENERAL LOG LEVELS IN YAZ ITSELF</title>
108 YAZ itself uses the following log levels:
111 <literal>fatal</literal> for fatal errors, that prevent further execution
115 <literal>warn</literal> for warnings about things that should be corrected.
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
124 <literal>all</literal> turns on almost all hard-coded log levels.
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
136 find . -name '*.[ch]' -print |
137 xargs grep yaz_log_module_level |
144 <literal>eventl</literal>, <literal>malloc</literal>,
145 <literal>nmem</literal>, <literal>odr</literal> are used internally for
152 <refsect1><title>LOG LEVELS FOR CLIENTS</title>
154 <literal>zoom</literal> logs the calls to the zoom API, which may be useful
155 in debugging client applications.
159 <refsect1><title>LOG LEVELS FOR SERVERS</title>
161 <literal>server</literal> logs the server functions on a high level,
162 starting up, listening on a port, etc.
165 <literal>session</literal> logs individual sessions (connections).
168 <literal>request</literal> logs a one-liner for each request (init, search,
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.
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.
182 <refsect1><title>LOGGING EXAMPLES</title>
184 See what log levels yaz-ztest is using:
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'
209 See the details of the requests for yaz-ztest
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
236 <refsect1><title>LOG FILENAME EXAMPLES</title>
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.
244 A weekly log could be specified as
245 <literal>-l my_%Y%U.log</literal>.
249 <refsect1><title>FILES</title>
251 <filename><replaceable>prefix</replaceable>/include/yaz/log.h</filename>
252 <filename><replaceable>prefix</replaceable>/src/log.c</filename>
255 <refsect1><title>SEE ALSO</title>
258 <refentrytitle>yaz</refentrytitle>
259 <manvolnum>7</manvolnum>
263 <refentrytitle>yaz-ztest</refentrytitle>
264 <manvolnum>8</manvolnum>
268 <refentrytitle>yaz-client</refentrytitle>
269 <manvolnum>1</manvolnum>
273 <refentrytitle>strftime</refentrytitle>
274 <manvolnum>3</manvolnum>
280 <!-- Keep this comment at the end of the file
285 sgml-minimize-attributes:nil
286 sgml-always-quote-attributes:t
289 sgml-parent-document:nil
290 sgml-local-catalogs: nil
291 sgml-namecase-general:t