Sophie

Sophie

distrib > Fedora > 14 > i386 > by-pkgid > 864d1c3c3cd8df4e3a2692faf8776e05 > files > 1172

db4o-doc-7.4-2.fc13.i686.rpm

<html>
  <head>
    <META http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Customizing The Debug Message Output</title>
    <link rel="stylesheet" type="text/css" href="../../../style.css">
  </head>
  <body>
    <div class="CommonContent">
      <div class="CommonContentArea">
        <h1>Customizing The Debug Message Output</h1><script>
//We attach this function to a browser object as a variable so that if multiple of these blocks are
//present on the same page, then they will simply over-write eachother with the same function instead
//of generating a naming collision.
window.WikiCodeFormattingCopyToClipboard = function copyToClipboard(sID){
	var sContent = document.getElementById(sID).innerText;
	if( window.clipboardData && clipboardData.setData )
	{
		clipboardData.setData("Text", sContent);
	}
	else
	{
		alert("You must enable javascript access to your clipboard for this feature to work. Please referr to your browser documentation or Google search for instructions.");
	}
}
</script><p><a href="debug_messaging_system.html" class="wikiLink">Debug Messaging System</a> topic explains how to activate the debug messages in your
application. However the default console output has very limited possibilities
and can only be used effectively in console applications. To use debug
messaging system in any environment db4o gives you an API to
redirect debug output to another stream:</p><p></p><span name="cs_wiki_filter" csw_filters="cs"><p>c#:&nbsp;</p>

<p><code>IConfiguration.SetOut(System.IO.TextWriter)</code></p></span><span name="cs_wiki_filter" csw_filters="vb"><p>VB:&nbsp;</p>

<p><code>IConfiguration.SetOut(System.IO.TextWriter)</code></p></span><p>An example below
shows how to create and use a log file for debug messages:</p><span name="cs_wiki_filter" csw_filters="cs"><div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">DebugExample.cs: <span class="fscMemberName">SetCarsWithFileOutput</span></span></div><div class="fscCode"><pre ID="ResourcesReferenceTuningDebugging_Db4odebuggingCS.ZipsDebugExample.Cs_DebugExample.Cs_SetCarsWithFileOutput_752_67"><div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--><span style="color: #008080;">01</span><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/None.gif" align="top"/><span style="color: #0000FF;">private</span><span style="color: #000000;"> </span><span style="color: #0000FF;">static</span><span style="color: #000000;"> </span><span style="color: #0000FF;">void</span><span style="color: #000000;"> SetCarsWithFileOutput()
</span><span style="color: #008080;">02</span><span style="color: #000000;"><img id="ResourcesReferenceTuningDebugging_Db4odebuggingCS.ZipsDebugExample.Cs_DebugExample.Cs_SetCarsWithFileOutput_752_67_52_1230_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceTuningDebugging_Db4odebuggingCS.ZipsDebugExample.Cs_DebugExample.Cs_SetCarsWithFileOutput_752_67_52_1230_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceTuningDebugging_Db4odebuggingCS.ZipsDebugExample.Cs_DebugExample.Cs_SetCarsWithFileOutput_752_67_52_1230_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceTuningDebugging_Db4odebuggingCS.ZipsDebugExample.Cs_DebugExample.Cs_SetCarsWithFileOutput_752_67_52_1230_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceTuningDebugging_Db4odebuggingCS.ZipsDebugExample.Cs_DebugExample.Cs_SetCarsWithFileOutput_752_67_52_1230_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceTuningDebugging_Db4odebuggingCS.ZipsDebugExample.Cs_DebugExample.Cs_SetCarsWithFileOutput_752_67_52_1230_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceTuningDebugging_Db4odebuggingCS.ZipsDebugExample.Cs_DebugExample.Cs_SetCarsWithFileOutput_752_67_52_1230_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceTuningDebugging_Db4odebuggingCS.ZipsDebugExample.Cs_DebugExample.Cs_SetCarsWithFileOutput_752_67_52_1230_Open_Text').style.display='inline';"/>        </span><span id="ResourcesReferenceTuningDebugging_Db4odebuggingCS.ZipsDebugExample.Cs_DebugExample.Cs_SetCarsWithFileOutput_752_67_52_1230_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceTuningDebugging_Db4odebuggingCS.ZipsDebugExample.Cs_DebugExample.Cs_SetCarsWithFileOutput_752_67_52_1230_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">03</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #008000;">//</span><span style="color: #008000;"> Create StreamWriter for a file</span><span style="color: #008000;">
</span><span style="color: #008080;">04</span><span style="color: #008000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/></span><span style="color: #000000;">            FileInfo f </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> FileInfo(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Debug.txt</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">);
</span><span style="color: #008080;">05</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            StreamWriter debugWriter </span><span style="color: #000000;">=</span><span style="color: #000000;"> f.CreateText();
</span><span style="color: #008080;">06</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>
</span><span style="color: #008080;">07</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            IConfiguration configuration </span><span style="color: #000000;">=</span><span style="color: #000000;"> Db4oFactory.NewConfiguration();
</span><span style="color: #008080;">08</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #008000;">//</span><span style="color: #008000;"> Redirect debug output to the specified writer</span><span style="color: #008000;">
</span><span style="color: #008080;">09</span><span style="color: #008000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/></span><span style="color: #000000;">            configuration.SetOut(debugWriter);
</span><span style="color: #008080;">10</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>
</span><span style="color: #008080;">11</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #008000;">//</span><span style="color: #008000;"> Set the debug message levet to the maximum</span><span style="color: #008000;">
</span><span style="color: #008080;">12</span><span style="color: #008000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/></span><span style="color: #000000;">            configuration.MessageLevel(</span><span style="color: #800080;">3</span><span style="color: #000000;">);
</span><span style="color: #008080;">13</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #008000;">//</span><span style="color: #008000;"> Do some db4o operations</span><span style="color: #008000;">
</span><span style="color: #008080;">14</span><span style="color: #008000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/></span><span style="color: #000000;">            File.Delete(Db4oFileName);
</span><span style="color: #008080;">15</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            IObjectContainer db </span><span style="color: #000000;">=</span><span style="color: #000000;"> Db4oFactory.OpenFile(Db4oFileName);
</span><span style="color: #008080;">16</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">try</span><span style="color: #000000;">
</span><span style="color: #008080;">17</span><span style="color: #000000;"><img id="ResourcesReferenceTuningDebugging_Db4odebuggingCS.ZipsDebugExample.Cs_DebugExample.Cs_SetCarsWithFileOutput_752_67_669_1054_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceTuningDebugging_Db4odebuggingCS.ZipsDebugExample.Cs_DebugExample.Cs_SetCarsWithFileOutput_752_67_669_1054_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceTuningDebugging_Db4odebuggingCS.ZipsDebugExample.Cs_DebugExample.Cs_SetCarsWithFileOutput_752_67_669_1054_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceTuningDebugging_Db4odebuggingCS.ZipsDebugExample.Cs_DebugExample.Cs_SetCarsWithFileOutput_752_67_669_1054_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceTuningDebugging_Db4odebuggingCS.ZipsDebugExample.Cs_DebugExample.Cs_SetCarsWithFileOutput_752_67_669_1054_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceTuningDebugging_Db4odebuggingCS.ZipsDebugExample.Cs_DebugExample.Cs_SetCarsWithFileOutput_752_67_669_1054_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceTuningDebugging_Db4odebuggingCS.ZipsDebugExample.Cs_DebugExample.Cs_SetCarsWithFileOutput_752_67_669_1054_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceTuningDebugging_Db4odebuggingCS.ZipsDebugExample.Cs_DebugExample.Cs_SetCarsWithFileOutput_752_67_669_1054_Open_Text').style.display='inline';"/>            </span><span id="ResourcesReferenceTuningDebugging_Db4odebuggingCS.ZipsDebugExample.Cs_DebugExample.Cs_SetCarsWithFileOutput_752_67_669_1054_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceTuningDebugging_Db4odebuggingCS.ZipsDebugExample.Cs_DebugExample.Cs_SetCarsWithFileOutput_752_67_669_1054_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">18</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                Car car1 </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> Car(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">BMW</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">);
</span><span style="color: #008080;">19</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                db.Set(car1);
</span><span style="color: #008080;">20</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                Car car2 </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> Car(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Ferrari</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">);
</span><span style="color: #008080;">21</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                db.Set(car2);
</span><span style="color: #008080;">22</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                db.Deactivate(car1, </span><span style="color: #800080;">2</span><span style="color: #000000;">);
</span><span style="color: #008080;">23</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                IQuery query </span><span style="color: #000000;">=</span><span style="color: #000000;"> db.Query();
</span><span style="color: #008080;">24</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                query.Constrain(</span><span style="color: #0000FF;">typeof</span><span style="color: #000000;">(Car));
</span><span style="color: #008080;">25</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                IObjectSet results </span><span style="color: #000000;">=</span><span style="color: #000000;"> query.Execute();
</span><span style="color: #008080;">26</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                ListResult(results);
</span><span style="color: #008080;">27</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top"/>            }</span></span><span style="color: #000000;">
</span><span style="color: #008080;">28</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">finally</span><span style="color: #000000;">
</span><span style="color: #008080;">29</span><span style="color: #000000;"><img id="ResourcesReferenceTuningDebugging_Db4odebuggingCS.ZipsDebugExample.Cs_DebugExample.Cs_SetCarsWithFileOutput_752_67_1087_1167_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceTuningDebugging_Db4odebuggingCS.ZipsDebugExample.Cs_DebugExample.Cs_SetCarsWithFileOutput_752_67_1087_1167_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceTuningDebugging_Db4odebuggingCS.ZipsDebugExample.Cs_DebugExample.Cs_SetCarsWithFileOutput_752_67_1087_1167_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceTuningDebugging_Db4odebuggingCS.ZipsDebugExample.Cs_DebugExample.Cs_SetCarsWithFileOutput_752_67_1087_1167_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceTuningDebugging_Db4odebuggingCS.ZipsDebugExample.Cs_DebugExample.Cs_SetCarsWithFileOutput_752_67_1087_1167_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceTuningDebugging_Db4odebuggingCS.ZipsDebugExample.Cs_DebugExample.Cs_SetCarsWithFileOutput_752_67_1087_1167_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceTuningDebugging_Db4odebuggingCS.ZipsDebugExample.Cs_DebugExample.Cs_SetCarsWithFileOutput_752_67_1087_1167_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceTuningDebugging_Db4odebuggingCS.ZipsDebugExample.Cs_DebugExample.Cs_SetCarsWithFileOutput_752_67_1087_1167_Open_Text').style.display='inline';"/>            </span><span id="ResourcesReferenceTuningDebugging_Db4odebuggingCS.ZipsDebugExample.Cs_DebugExample.Cs_SetCarsWithFileOutput_752_67_1087_1167_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceTuningDebugging_Db4odebuggingCS.ZipsDebugExample.Cs_DebugExample.Cs_SetCarsWithFileOutput_752_67_1087_1167_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">30</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                db.Close();
</span><span style="color: #008080;">31</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                debugWriter.Close();
</span><span style="color: #008080;">32</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top"/>            }</span></span><span style="color: #000000;">
</span><span style="color: #008080;">33</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            Db4oFactory.Configure().MessageLevel(</span><span style="color: #800080;">0</span><span style="color: #000000;">);
</span><span style="color: #008080;">34</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockEnd.gif" align="top"/>        }</span></span></div></pre></div></div></span><span name="cs_wiki_filter" csw_filters="vb">
<div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">DebugExample.vb: <span class="fscMemberName">SetCarsWithFileOutput</span></span></div><div class="fscCode"><pre ID="ResourcesReferenceTuningDebugging_Db4odebuggingVB.ZipsDebugExample.Vb_DebugExample.Vb_SetCarsWithFileOutput_873_67"><div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--><span style="color: #008080;">01</span><img id="ResourcesReferenceTuningDebugging_Db4odebuggingVB.ZipsDebugExample.Vb_DebugExample.Vb_SetCarsWithFileOutput_873_67_15_1162_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceTuningDebugging_Db4odebuggingVB.ZipsDebugExample.Vb_DebugExample.Vb_SetCarsWithFileOutput_873_67_15_1162_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceTuningDebugging_Db4odebuggingVB.ZipsDebugExample.Vb_DebugExample.Vb_SetCarsWithFileOutput_873_67_15_1162_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceTuningDebugging_Db4odebuggingVB.ZipsDebugExample.Vb_DebugExample.Vb_SetCarsWithFileOutput_873_67_15_1162_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceTuningDebugging_Db4odebuggingVB.ZipsDebugExample.Vb_DebugExample.Vb_SetCarsWithFileOutput_873_67_15_1162_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceTuningDebugging_Db4odebuggingVB.ZipsDebugExample.Vb_DebugExample.Vb_SetCarsWithFileOutput_873_67_15_1162_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceTuningDebugging_Db4odebuggingVB.ZipsDebugExample.Vb_DebugExample.Vb_SetCarsWithFileOutput_873_67_15_1162_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceTuningDebugging_Db4odebuggingVB.ZipsDebugExample.Vb_DebugExample.Vb_SetCarsWithFileOutput_873_67_15_1162_Open_Text').style.display='inline';"/><span style="color: #0000FF;">Private</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Shared</span><span style="color: #000000;"> </span><span id="ResourcesReferenceTuningDebugging_Db4odebuggingVB.ZipsDebugExample.Vb_DebugExample.Vb_SetCarsWithFileOutput_873_67_15_1162_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">Sub SetCarsWithFileOutput()</span><span id="ResourcesReferenceTuningDebugging_Db4odebuggingVB.ZipsDebugExample.Vb_DebugExample.Vb_SetCarsWithFileOutput_873_67_15_1162_Open_Text"><span style="color: #0000FF;">Sub</span><span style="color: #000000;"> SetCarsWithFileOutput()
</span><span style="color: #008080;">02</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #008000;">'</span><span style="color: #008000;"> Create StreamWriter for a file</span><span style="color: #008000;">
</span><span style="color: #008080;">03</span><span style="color: #008000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/></span><span style="color: #000000;">            </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> f </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> FileInfo </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">New</span><span style="color: #000000;"> FileInfo(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Debug.txt</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">)
</span><span style="color: #008080;">04</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> debugWriter </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> StreamWriter </span><span style="color: #000000;">=</span><span style="color: #000000;"> f.CreateText()
</span><span style="color: #008080;">05</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>
</span><span style="color: #008080;">06</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #008000;">'</span><span style="color: #008000;"> Redirect debug output to the specified writer</span><span style="color: #008000;">
</span><span style="color: #008080;">07</span><span style="color: #008000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/></span><span style="color: #000000;">            Db4oFactory.Configure().SetOut(debugWriter)
</span><span style="color: #008080;">08</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>
</span><span style="color: #008080;">09</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #008000;">'</span><span style="color: #008000;"> Set the debug message levet to the maximum</span><span style="color: #008000;">
</span><span style="color: #008080;">10</span><span style="color: #008000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/></span><span style="color: #000000;">            Db4oFactory.Configure().MessageLevel(</span><span style="color: #800080;">3</span><span style="color: #000000;">)
</span><span style="color: #008080;">11</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #008000;">'</span><span style="color: #008000;"> Do some db4o operations</span><span style="color: #008000;">
</span><span style="color: #008080;">12</span><span style="color: #008000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/></span><span style="color: #000000;">            File.Delete(Db4oFileName)
</span><span style="color: #008080;">13</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> db </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IObjectContainer </span><span style="color: #000000;">=</span><span style="color: #000000;"> Db4oFactory.OpenFile(Db4oFileName)
</span><span style="color: #008080;">14</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Try</span><span style="color: #000000;">
</span><span style="color: #008080;">15</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> car1 </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> Car </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">New</span><span style="color: #000000;"> Car(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">BMW</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">)
</span><span style="color: #008080;">16</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                db.Set(car1)
</span><span style="color: #008080;">17</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> car2 </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> Car </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">New</span><span style="color: #000000;"> Car(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Ferrari</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">)
</span><span style="color: #008080;">18</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                db.Set(car2)
</span><span style="color: #008080;">19</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                db.Deactivate(car1, </span><span style="color: #800080;">2</span><span style="color: #000000;">)
</span><span style="color: #008080;">20</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> query </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IQuery </span><span style="color: #000000;">=</span><span style="color: #000000;"> db.Query()
</span><span style="color: #008080;">21</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                query.Constrain(</span><span style="color: #0000FF;">GetType</span><span style="color: #000000;">(Car))
</span><span style="color: #008080;">22</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> results </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IObjectSet </span><span style="color: #000000;">=</span><span style="color: #000000;"> query.Execute()
</span><span style="color: #008080;">23</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                ListResult(results)
</span><span style="color: #008080;">24</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Finally</span><span style="color: #000000;">
</span><span style="color: #008080;">25</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                db.Close()
</span><span style="color: #008080;">26</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                debugWriter.Close()
</span><span style="color: #008080;">27</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">End</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Try</span><span style="color: #000000;">
</span><span style="color: #008080;">28</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            Db4oFactory.Configure().MessageLevel(</span><span style="color: #800080;">0</span><span style="color: #000000;">)
</span><span style="color: #008080;">29</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockEnd.gif" align="top"/>        </span><span style="color: #0000FF;">End Sub</span></span></div></pre></div></div>
</span>
<p>Using a log file
for debug messages has several advantages:</p>

<ul><li>debug information
is available after the application has terminated;</li><li>console output is
not polluted with debug messages;</li><li>debug information
from the clients can be available on the server.</li></ul>





<p>You can always
switch back to the default setting using:</p><span name="cs_wiki_filter" csw_filters="cs"><p>c#:&nbsp;</p><p><code>IConfiguration.SetOut(System.Console.Out)</code></p></span><span name="cs_wiki_filter" csw_filters="vb"><p>VB:&nbsp;</p><p><code>IConfiguration.SetOut(System.Console.Out)</code></p></span></div>
    </div>
    <div id="footer">
					This revision (3) was last Modified 2007-01-18T19:21:03 by Tetyana.
				</div>
  </body>
</html>