1<?xml version="1.0" encoding="UTF-8" standalone="no"?> 2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 3<html xmlns="http://www.w3.org/1999/xhtml"> 4 <head> 5 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 6 <title>DB->set_errfile()</title> 7 <link rel="stylesheet" href="apiReference.css" type="text/css" /> 8 <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" /> 9 <link rel="start" href="index.html" title="Berkeley DB C API Reference" /> 10 <link rel="up" href="db.html" title="Chapter��2.�� The DB Handle" /> 11 <link rel="prev" href="dbset_errcall.html" title="DB->set_errcall()" /> 12 <link rel="next" href="dbset_errpfx.html" title="DB->set_errpfx()" /> 13 </head> 14 <body> 15 <div class="navheader"> 16 <table width="100%" summary="Navigation header"> 17 <tr> 18 <th colspan="3" align="center">DB->set_errfile()</th> 19 </tr> 20 <tr> 21 <td width="20%" align="left"><a accesskey="p" href="dbset_errcall.html">Prev</a>��</td> 22 <th width="60%" align="center">Chapter��2.�� 23 The DB Handle 24 </th> 25 <td width="20%" align="right">��<a accesskey="n" href="dbset_errpfx.html">Next</a></td> 26 </tr> 27 </table> 28 <hr /> 29 </div> 30 <div class="sect1" lang="en" xml:lang="en"> 31 <div class="titlepage"> 32 <div> 33 <div> 34 <h2 class="title" style="clear: both"><a id="dbset_errfile"></a>DB->set_errfile()</h2> 35 </div> 36 </div> 37 </div> 38 <pre class="programlisting">#include <db.h> 39 40void 41DB->set_errfile(DB *db, FILE *errfile); </pre> 42 <p> 43 When an error occurs in the Berkeley DB library, 44 <span> 45 a Berkeley DB error 46 </span> 47 48 or an error return value is returned by the interface. In some cases, 49 however, the <span class="bold"><strong>errno</strong></span> value may be 50 insufficient to completely describe the cause of the error, especially 51 during initial application debugging. 52 </p> 53 <p> 54 The <a class="xref" href="envset_errfile.html" title="DB_ENV->set_errfile()">DB_ENV->set_errfile()</a> and 55 <code class="methodname">DB->set_errfile()</code> methods are used to enhance the mechanism for 56 reporting error messages to the application by setting a C library 57 FILE * to be used for displaying additional Berkeley DB error 58 messages. In some cases, when an error occurs, Berkeley DB will 59 output an additional error message to the specified file reference. 60 </p> 61 <p> 62 Alternatively, you can use the 63 64 65 <a class="xref" href="envset_errcall.html" title="DB_ENV->set_errcall()">DB_ENV->set_errcall()</a> or 66 <a class="xref" href="dbset_errcall.html" title="DB->set_errcall()">DB->set_errcall()</a> 67 methods to capture the additional error information in a way that does 68 not use C library FILE *'s. 69 70 </p> 71 <p> 72 The error message will consist of the prefix string and a colon 73 ("<span class="bold"><strong>:</strong></span>") (if a prefix string was 74 previously specified using 75 <a class="xref" href="dbset_errpfx.html" title="DB->set_errpfx()">DB->set_errpfx()</a> or 76 <a class="xref" href="envset_errpfx.html" title="DB_ENV->set_errpfx()">DB_ENV->set_errpfx()</a> ), an 77 error string, and a trailing <newline> character. 78 </p> 79 <p> 80 The default configuration when applications first create 81 <a class="link" href="db.html" title="Chapter��2.�� The DB Handle">DB</a> or 82 <a class="link" href="env.html" title="Chapter��5.�� The DB_ENV Handle">DB_ENV</a> handles is as if the 83 <a class="xref" href="envset_errfile.html" title="DB_ENV->set_errfile()">DB_ENV->set_errfile()</a> or 84 <code class="methodname">DB->set_errfile()</code> methods were called with the standard error output 85 (stderr) specified as the FILE * argument. Applications wanting no 86 output at all can turn off this default configuration by calling the 87 <a class="xref" href="envset_errfile.html" title="DB_ENV->set_errfile()">DB_ENV->set_errfile()</a> or 88 <code class="methodname">DB->set_errfile()</code> methods with NULL as the FILE * argument. 89 Additionally, explicitly configuring the error output channel using 90 any of the following methods will also turn off this default output for the application: 91 </p> 92 <div class="itemizedlist"> 93 <ul type="disc"> 94 <li> 95 <p> 96 <code class="methodname">DB->set_errfile()</code> 97 </p> 98 </li> 99 <li> 100 <p> 101 <a class="xref" href="envset_errfile.html" title="DB_ENV->set_errfile()">DB_ENV->set_errfile()</a> 102 </p> 103 </li> 104 <li> 105 <p> 106 <a class="xref" href="envset_errcall.html" title="DB_ENV->set_errcall()">DB_ENV->set_errcall()</a> 107 </p> 108 </li> 109 <li> 110 <p> 111 <a class="xref" href="dbset_errcall.html" title="DB->set_errcall()">DB->set_errcall()</a> 112 </p> 113 </li> 114 </ul> 115 </div> 116 <p> 117 This error logging enhancement does not slow performance or 118 significantly increase application size, and may be run during normal 119 operation as well as during application debugging. 120 </p> 121 <p> 122 For <a class="link" href="db.html" title="Chapter��2.�� The DB Handle">DB</a> handles opened 123 inside of Berkeley DB environments, calling the 124 <code class="methodname">DB->set_errfile()</code> 125 method affects the entire environment and is equivalent to calling the 126 <a class="xref" href="envset_errfile.html" title="DB_ENV->set_errfile()">DB_ENV->set_errfile()</a> 127 method. 128 </p> 129 <p> 130 When used on a database that was <span class="emphasis"><em>not</em></span> opened in 131 an environment, the <code class="methodname">DB->set_errfile()</code> 132 method configures operations performed using the specified 133 <a class="link" href="db.html" title="Chapter��2.�� The DB Handle">DB</a> handle, not all operations 134 performed on the underlying database. 135 </p> 136 <p> 137 The <code class="methodname">DB->set_errfile()</code> method may be called at any time during the 138 life of the application. 139 </p> 140 <div class="sect2" lang="en" xml:lang="en"> 141 <div class="titlepage"> 142 <div> 143 <div> 144 <h3 class="title"><a id="id1645690"></a>Parameters</h3> 145 </div> 146 </div> 147 </div> 148 <div class="sect3" lang="en" xml:lang="en"> 149 <div class="titlepage"> 150 <div> 151 <div> 152 <h4 class="title"><a id="id1645628"></a>errfile</h4> 153 </div> 154 </div> 155 </div> 156 <p> 157 The <span class="bold"><strong>errfile</strong></span> parameter is a C library 158 <code class="literal">FILE *</code> to be used for displaying additional Berkeley DB error 159 information. 160 </p> 161 </div> 162 </div> 163 <div class="sect2" lang="en" xml:lang="en"> 164 <div class="titlepage"> 165 <div> 166 <div> 167 <h3 class="title"><a id="id1646020"></a>Class</h3> 168 </div> 169 </div> 170 </div> 171 <p> 172 <a class="link" href="db.html" title="Chapter��2.�� The DB Handle">DB</a> 173 </p> 174 </div> 175 <div class="sect2" lang="en" xml:lang="en"> 176 <div class="titlepage"> 177 <div> 178 <div> 179 <h3 class="title"><a id="id1645947"></a>See Also</h3> 180 </div> 181 </div> 182 </div> 183 <p> 184 <a class="xref" href="db.html#dblist" title="Database and Related Methods">Database and Related Methods</a> 185 </p> 186 </div> 187 </div> 188 <div class="navfooter"> 189 <hr /> 190 <table width="100%" summary="Navigation footer"> 191 <tr> 192 <td width="40%" align="left"><a accesskey="p" href="dbset_errcall.html">Prev</a>��</td> 193 <td width="20%" align="center"> 194 <a accesskey="u" href="db.html">Up</a> 195 </td> 196 <td width="40%" align="right">��<a accesskey="n" href="dbset_errpfx.html">Next</a></td> 197 </tr> 198 <tr> 199 <td width="40%" align="left" valign="top">DB->set_errcall()��</td> 200 <td width="20%" align="center"> 201 <a accesskey="h" href="index.html">Home</a> 202 </td> 203 <td width="40%" align="right" valign="top">��DB->set_errpfx()</td> 204 </tr> 205 </table> 206 </div> 207 </body> 208</html> 209