<docbook><section><title>GeneratingFreeTDSLogFile</title><para> </para><title> Generating TDS Protocol Logs </title> Generating TDS Protocol Logs 
<bridgehead class="http://www.w3.org/1999/xhtml:h2"> Basic information </bridgehead>
<para>Our ODBC Drivers for Sybase and Microsoft SQL Server use the FreeTDS Libraries for their network connectivity layer.</para><para>Most troubleshooting of these drivers can be done through the ordinary <ulink url="GeneratingClientsideODBCTracesAllDrivers">ODBC Traces and Driver Debug Logs</ulink>, but sometimes protocol-level logs are necessary.</para><bridgehead class="http://www.w3.org/1999/xhtml:h2"> Specifics </bridgehead>
<para>TDS protocol logging is enabled by setting the <emphasis>TDSDUMP</emphasis> environment variable to the name of the file where the log should be written.</para><para>Environment variables are set differently on different operating systems.</para><para>With Enterprise Edition (Multi-Tier), this may be set in the [Environment ...] stanza that&#39;s active for the connections in question.
 It may also be set before starting the Broker (such that it&#39;s set for the Broker process, and inherited by all its child Agent processes).</para><para>With Lite Edition (Single-Tier), this may be set in the relevant stanza of the openlink.ini file on Unix-like OS, or for the active login session before launching the ODBC client application on Windows, macOS, or Unix-like OS.</para><bridgehead class="http://www.w3.org/1999/xhtml:h3"> macOS a/k/a Mac OS X </bridgehead>
<para>Details vary with different versions of macOS.</para><bridgehead class="http://www.w3.org/1999/xhtml:h4"> Mojave (10.14), High Sierra (10.13), Sierra (10.12), El Capitan (10.11), Yosemite (10.10), Mavericks (10.9), Mountain Lion (10.8), or Lion (10.7) </bridgehead>
<para>As of Lion, these simple <computeroutput>Terminal.app</computeroutput> commands will do the job, creating the <computeroutput>tdsdump.txt</computeroutput> file on the ODBC user&#39;s Desktop.</para><itemizedlist mark="bullet" spacing="compact"><listitem> To enable TDS logging -- <programlisting>launchctl setenv TDSDUMP ~/Desktop/tdsdump.txt
</programlisting>It is often preferable to fully specify the path, &quot;<computeroutput>/Users/ShortUsername/</computeroutput>&quot;, instead of using the shortcut, &quot;<computeroutput>~/</computeroutput>&quot; -- <programlisting>launchctl setenv TDSDUMP /Users/ShortUsername/Desktop/tdsdump.txt
</programlisting></listitem>
</itemizedlist><itemizedlist mark="bullet" spacing="compact"><listitem> To disable TDS logging -- <programlisting>launchctl unsetenv TDSDUMP 
</programlisting></listitem>
</itemizedlist><para>Note that any active applications will not notice the change; you have to quit and relaunch.</para><para>A reboot or user log out will unset the variables set with these commands, and you&#39;ll need to re-set them afterward.
 Persistent settings (not usually appropriate for TDS logging) can be made through a <computeroutput>launchd.plist</computeroutput>, <ulink url="http://www.dowdandassociates.com/blog/content/howto-set-an-environment-variable-in-mac-os-x-launchd-plist/">as described elsewhere</ulink>.</para><para> </para><bridgehead class="http://www.w3.org/1999/xhtml:h4"> Lion (10.7), Snow Leopard (10.6), Leopard (10.5), Tiger (10.4), Panther (10.3), Jaguar (10.2), Puma (10.1), or Cheetah (10.0) </bridgehead>
<para>On Snow Leopard (10.6) and earlier, this is best done by creating (or editing) a file called <computeroutput>environment.plist</computeroutput> in a (normally invisible) directory called <computeroutput>.MacOSX</computeroutput>, in the user&#39;s home directory.
 This method also works on Lion (10.7).</para><para>You can execute either of these commands in <computeroutput>Terminal.app</computeroutput>, to open the file for editing in <computeroutput>TextEdit.app</computeroutput> -- </para><programlisting>open -e /Users/ShortUsername/.MacOSX/environment.plist

open -e ~/.MacOSX/environment.plist
</programlisting><para> If the file already exists, just add these two lines to the main <computeroutput>&lt;dict&gt;</computeroutput> block -- </para><programlisting>        &lt;key&gt;TDSDUMP&lt;/key&gt;
        &lt;string&gt;~/Desktop/tdsdump.txt&lt;/string&gt;
</programlisting><para> If you&#39;re creating a new file, make sure it contains this entire block -- </para><programlisting>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;!DOCTYPE plist PUBLIC &quot;-//Apple Computer//DTD PLIST 1.0//EN&quot; 
        &quot;http://www.apple.com/DTDs/PropertyList-1.0.dtd&quot;&gt;
&lt;plist version=&quot;1.0&quot;&gt;
&lt;dict&gt;
        &lt;key&gt;TDSDUMP&lt;/key&gt;
        &lt;string&gt;~/Desktop/tdsdump.txt&lt;/string&gt;
&lt;/dict&gt;
&lt;/plist&gt;
</programlisting><bridgehead class="http://www.w3.org/1999/xhtml:h3"> Unix-like OS (AIX, HP-UX, Linux, Solaris, etc.) </bridgehead>
<para>Commands vary with your active shell, among other variables, so we cannot provide an exhaustive list.
 A couple of examples -- </para><programlisting>export TDSDUMP=/tmp/freetds.log                 ## some Unix systems

set TDSDUMP=/tmp/freetds.log ; export TDSDUMP   ## other Unix systems
</programlisting><bridgehead class="http://www.w3.org/1999/xhtml:h3"> Windows (all versions) </bridgehead>
<para>You can send the log to any location in the accessible filesystem, local or remote.
 This is a simple example -- </para><programlisting>set TDSDUMP=C:\freetds.log
</programlisting><para> You can also use the <emphasis>System</emphasis> control panel, <emphasis>Advanced</emphasis> tab, <emphasis>Environment Variables</emphasis> button.</para><para> </para><bridgehead class="http://www.w3.org/1999/xhtml:h2"> For more information...
 </bridgehead>
<para>Further details on usage can be found on the <ulink url="http://www.freetds.org/userguide/logging.htm">FreeTDS Web Site</ulink>.
</para></section></docbook>