JezK
Edit File: logging.html
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Logging</title><link rel="stylesheet" type="text/css" href="userguide.css" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="home" href="index.html" title="FreeTDS User Guide" /><link rel="up" href="troubleshooting.html" title="Chapter 8. Troubleshooting" /><link rel="prev" href="serverthere.html" title="Is the server there?" /><link rel="next" href="pagenodata.html" title=""Page contains no data"" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Logging</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="serverthere.html">Prev</a> </td><th width="60%" align="center">Chapter 8. Troubleshooting</th><td width="20%" align="right"> <a accesskey="n" href="pagenodata.html">Next</a></td></tr></table><hr /></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="logging"></a>Logging</h2></div></div></div><p><span class="productname">FreeTDS</span> has quite extensive logging capabilities. These are often invaluable in setting up new configurations, when it's hard to be sure precisely what configuration information is being used, and what communication is (not) working. Often such questions can be quickly resolved by turning on logging and examining the logs.</p><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="Environment"></a>Environment Variables that Control Logging</h3></div></div></div><div class="variablelist"><a id="tab.Logging.control.envar"></a><dl class="variablelist"><dt><span class="term"><a id="TDSDUMP"></a><code class="envar">TDSDUMP</code></span></dt><dd><p>Log files can be turned on using the <code class="envar">TDSDUMP</code> environment variable. For instance, setting the location of a dumpfile </p><pre class="screen"> <code class="prompt">$ </code><strong class="userinput"><code>export TDSDUMP=/tmp/freetds.log</code></strong></pre><p> Will generate a log file named <code class="filename">freetds.log</code> in the <code class="filename">/tmp</code> directory. </p><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="../images/tip.gif" /></td><th align="left">Tip</th></tr><tr><td align="left" valign="top"><p> The filenames <code class="filename">stdout</code> and <code class="filename">stderr</code> are also supported. They can be handy if you want to intersperse the log output with your application's output, or if your application opens more than one connection. (The logfile is otherwise normally truncated each time the library connects to the server.)</p></td></tr></table></div></dd><dt><span class="term"><code class="envar">TDSDUMPCONFIG</code></span></dt><dd><p>Set <code class="envar">TDSDUMPCONFIG</code> to a file to write information to on how the configuration information is being obtained, e.g. from environment variables, a <code class="filename">freetds.conf</code> file, or <code class="filename">interfaces</code> file. Sometimes it's unclear what source of information <span class="productname">FreeTDS</span> is using to connect to a given servername. This variable can make that bright and clear.</p></dd></dl></div><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="../images/tip.gif" /></td><th align="left">Tip</th></tr><tr><td align="left" valign="top"><p>What if you were running <span class="productname">Apache</span>/PHP? <span class="productname">Apache</span> has many children. Setting the <code class="envar">TDSDUMP</code> (and/or <code class="envar">TDSDUMPCONFIG</code>) variable to a null string will cause <span class="productname">FreeTDS</span> to open a log under every PID. </p><pre class="screen"> <code class="prompt">$ </code><strong class="userinput"><code>export TDSDUMP=""</code></strong></pre><p> The log files will be named <code class="filename">/tmp/freetds.log.<em class="replaceable"><code>9999</code></em></code>, where <em class="replaceable"><code>9999</code></em> is the pid number of the process generating the log. </p></td></tr></table></div><p>A couple of important notes about using the logs with <span class="productname">FreeTDS</span>. First, the logs tend to grow large, so trim or archive them often. Secondly, <span class="productname">FreeTDS</span> will record certain network packets to the log, this <span class="emphasis"><em>includes login packets which can contain clear text or clear text equivalent passwords.</em></span> So, if this is a concern (most likely is) make sure that the files are not world readable, and avoid posting them to mailing lists.</p><p>Once in a while, someone writes to the mailing list, asking why <span class="productname">FreeTDS</span> is so <span class="emphasis"><em>slow</em></span>. It sometimes turns out that logging was left turned on. Don't you be the next victim! <span class="productname">FreeTDS</span> logs are meant for development and debugging, not as a system monitoring tool.</p></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="Logging.freetds.conf"></a><code class="filename">freetds.conf</code> variables that Control Logging</h3></div></div></div><p>See <a class="link" href="freetdsconf.html#tab.freetds.conf.debugflags" title="Table 3.4. Valid bitmask values for debug flags entry in freetds.conf">Valid bitmask values for <code class="literal">debug flags</code> entry in <code class="filename">freetds.conf</code></a></p><p>The logfile is normally truncated each time <span class="productname">FreeTDS</span> connects to the server.</p></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="Logging.odbc"></a>Logging in ODBC land</h3></div><div><h4 class="subtitle">(Tree-huggers need not worry)</h4></div></div></div><p>Many ODBC Driver Managers have their own support for logging. How logging is controlled, however, varies widely by implementation. The ODBC log is often very helpful because it provides a log of all calls made directly by the application.</p><div class="variablelist"><dl class="variablelist"><dt><span class="term">unixODBC</span></dt><dd><p><code class="systemitem">unixODBC</code> supports logging via some entries in <code class="filename">odbcinst.ini</code>. For example: </p><pre class="screen"> [ODBC] Trace = Yes TraceFile = /tmp/sql.log ForceTrace = Yes</pre><p> Will generate a log file named <code class="filename">sql.log</code> in the <code class="filename">/tmp</code> directory.</p></dd></dl></div></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="serverthere.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="troubleshooting.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="pagenodata.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Is the server there? </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> "Page contains no data"</td></tr></table></div></body></html>