You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ibatis.apache.org by gb...@apache.org on 2006/01/14 18:34:44 UTC

svn commit: r369061 - /ibatis/trunk/cs/docs/dataAccessGuide/src/en/configuration.xml

Author: gbayon
Date: Sat Jan 14 09:34:40 2006
New Revision: 369061

URL: http://svn.apache.org/viewcvs?rev=369061&view=rev
Log:
- Added logging configuration in DataAccess Guide

Modified:
    ibatis/trunk/cs/docs/dataAccessGuide/src/en/configuration.xml

Modified: ibatis/trunk/cs/docs/dataAccessGuide/src/en/configuration.xml
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/docs/dataAccessGuide/src/en/configuration.xml?rev=369061&r1=369060&r2=369061&view=diff
==============================================================================
--- ibatis/trunk/cs/docs/dataAccessGuide/src/en/configuration.xml (original)
+++ ibatis/trunk/cs/docs/dataAccessGuide/src/en/configuration.xml Sat Jan 14 09:34:40 2006
@@ -140,12 +140,9 @@
           <filename>Castle.DynamicProxy.dll</filename> (creating proxies)
         </listitem>
 
-        <listitem>
-          <filename>log4net.dll</filename> (logging)
-        </listitem>
       </orderedlist>
-      Both of these dependencies
-      are found in the <filename>External-Bin</filename> folder and can also
+      The dependency
+      is found in the <filename>External-Bin</filename> folder and can also
       be found in the <filename>bin\Debug</filename> folder after building the
       solution. In addition, the framework's
       <filename>IBatisNet.DataAccess.Extensions</filename> and
@@ -201,23 +198,6 @@
                 <entry>Castle.DynamicProxy.dll</entry>
               </row>
 
-              <row>
-                <entry>Log4NET 1.2.9</entry>
-
-                <entry>Logging framework</entry>
-
-                <entry>log4net.dll</entry>
-              </row>
-
-              <row>
-                <entry>NHibernate </entry>
-
-                <entry>Object persistence library; required if using
-                NHibernate DAO Session Handler</entry>
-
-                <entry>HashCodeProvider.dll NHibernate.dll
-                Iesi.Collections.dll</entry>
-              </row>
             </tbody>
           </tgroup>
         </table></para>
@@ -279,6 +259,189 @@
     </sect2>
   </sect1>
 
+ <sect1>
+    <title>Logging Activity</title>
+
+    <para>The iBATIS DataAccess framework records its interaction with the
+    database through an internal logging mechanism patterned after Apache
+    Log4Net. The internal logging mechanism can use one of the three built-in
+    loggers (NoOpLogger, ConsoleOutLogger, TraceLogger) or external logging
+    packages such as Apache Log4Net. In order for iBATIS to generate log
+    messages, the application's config file (App.Config or Web.Config) must
+    contain an appropriate configSection node:</para>
+
+    <example>
+      <title>iBATIS Configuration Section Handler for logging</title>
+
+      <programlisting>&lt;configSections&gt;
+ &lt;sectionGroup name="iBATIS"&gt;
+  &lt;section name="logging" type="IBatisNet.Common.Logging.ConfigurationSectionHandler, IBatisNet.Common" /&gt;
+ &lt;/sectionGroup&gt;
+&lt;/configSections&gt;</programlisting>
+    </example>
+
+    <para>The application's config file must declare one logger
+    implementation. See the examples below on how to configure one of the
+    three built-in loggers.</para>
+
+    <para><programlisting>&lt;iBATIS&gt;
+ &lt;logging&gt;
+  &lt;logFactoryAdapter type="IBatisNet.Common.Logging.Impl.ConsoleOutLoggerFA, IBatisNet.Common"&gt;
+   &lt;arg key="showLogName" value="true" /&gt;
+   &lt;arg key="showDataTime" value="true" /&gt;
+   &lt;arg key="level" value="ALL" /&gt;
+   &lt;arg key="dateTimeFormat" value="yyyy/MM/dd HH:mm:ss:SSS" /&gt;
+  &lt;/logFactoryAdapter&gt;
+ &lt;/logging&gt;
+&lt;/iBATIS&gt;
+</programlisting><programlisting>&lt;iBATIS&gt;
+ &lt;logging&gt;
+  &lt;logFactoryAdapter type="IBatisNet.Common.Logging.Impl.NoOpLoggerFA, IBatisNet.Common" /&gt;
+ &lt;/logging&gt;
+&lt;/iBATIS&gt;
+</programlisting><programlisting>&lt;iBATIS&gt;
+ &lt;logging&gt;
+  &lt;logFactoryAdapter type="IBatisNet.Common.Logging.Impl.TraceLoggerFA, IBatisNet.Common" /&gt;
+ &lt;/logging&gt;
+&lt;/iBATIS&gt;</programlisting></para>
+
+    <para>To configure iBATIS to use another logger implementation, simple
+    specify the appropriate logFactoryAdapter type. To use Apache Log4Net with
+    the iBATIS framework, use the following configuration
+    setting:</para>
+
+    <para><programlisting>&lt;iBATIS&gt;
+ &lt;logging&gt;
+  &lt;logFactoryAdapter type="IBatisNet.Common.Logging.Impl.Log4NetLoggerFA, IBatisNet.Common.Logging.Log4Net"&gt;
+   &lt;arg key="configType" value="inline" /&gt;
+  &lt;/logFactoryAdapter&gt;
+ &lt;/logging&gt;
+&lt;/iBATIS&gt;</programlisting></para>
+
+    <para><programlisting>&lt;iBATIS&gt;
+ &lt;logging&gt;
+  &lt;logFactoryAdapter type="IBatisNet.Common.Logging.Impl.Log4NetLoggerFA, IBatisNet.Common.Logging.Log4Net"&gt;
+   &lt;arg key="configType" value="file" /&gt;
+   &lt;arg key="configFile" value="log4Net.config" /&gt;
+  &lt;/logFactoryAdapter&gt;
+ &lt;/logging&gt;
+&lt;/iBATIS&gt;</programlisting></para>
+
+    <para>The Log4NetLoggerFA supports the following values for the
+    configTypes argument:<table>
+        <title>Valid configType values</title>
+
+        <tgroup cols="2">
+          <thead>
+            <row>
+              <entry>configType</entry>
+
+              <entry>Description</entry>
+            </row>
+          </thead>
+
+          <tbody>
+            <row>
+              <entry>inline</entry>
+
+              <entry>log4net node will use the log4net node in the
+              App.Config/Web.Config file when it is configured</entry>
+            </row>
+
+            <row>
+              <entry>file</entry>
+
+              <entry>(also requires configFile argument) - log4net will use an
+              external file for its configuration</entry>
+            </row>
+
+            <row>
+              <entry>file-watch</entry>
+
+              <entry> (also requires configFile argument) - log4net will use
+              an external file for its configuration and will re-configure
+              itself if this file changes</entry>
+            </row>
+
+            <row>
+              <entry>external</entry>
+
+              <entry>iBATIS will not attempt to configure log4net.</entry>
+            </row>
+          </tbody>
+        </tgroup>
+      </table></para>
+
+	  <sect2>
+      <title>Sample Logging Configurations</title>
+
+      <para>The simplest logging configuration is to output log messages to
+      Console.Out:</para>
+
+      <para><programlisting>&lt;configuration&gt;
+ &lt;configSections&gt;
+  &lt;sectionGroup name="iBATIS"&gt;
+   &lt;section name="logging" type="IBatisNet.Common.Logging.ConfigurationSectionHandler, IBatisNet.Common" /&gt;
+  &lt;/sectionGroup&gt;
+ &lt;/configSections&gt;
+ &lt;iBATIS&gt;
+  &lt;logging&gt;
+   &lt;logFactoryAdapter type="IBatisNet.Common.Logging.Impl.ConsoleLoggerFA, IBatisNet.Common.Logging" /&gt;
+  &lt;/logging&gt;
+ &lt;/iBATIS&gt;
+&lt;/configuration&gt;</programlisting></para>
+
+      <para>A common logging configuration is to use Apache Log4Net. To use
+      Log4Net with your own application, you need to provide your own Log4Net
+      configuration. You can do this by adding a configuration file for your
+      assembly that includes a &lt;log4Net&gt; element. The configuration file
+      is named after your assembly but adds a <filename>.config</filename>
+      extension, and is stored in the same folder as your assembly. This is an
+      example of a basic Log4Net configuration block
+      (IBatisNet.DataMapper.Test.dll.Config) that also creates a log4net.txt
+      which contains debug information from log4net. If log4net is not
+      producing output, check the log4net.txt file.</para>
+
+      <para><programlisting>&lt;configuration&gt;
+ &lt;configSections&gt;
+  &lt;sectionGroup name="iBATIS"&gt;
+   &lt;section name="logging" type="IBatisNet.Common.Logging.ConfigurationSectionHandler, IBatisNet.Common" /&gt;
+  &lt;/sectionGroup&gt;
+  &lt;section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" /&gt;
+ &lt;/configSections&gt;
+ &lt;appSettings&gt;
+  &lt;add key="log4net.Internal.Debug" value="true"/&gt;
+ &lt;/appSettings&gt;
+ &lt;system.diagnostics&gt;
+ &lt;trace autoflush="true"&gt;
+   &lt;listeners&gt;
+    &lt;add name="textWriterTraceListener" 
+     type="System.Diagnostics.TextWriterTraceListener"
+     initializeData="C:\\inetpub\\wwwroot\\log4net.txt" /&gt;
+   &lt;/listeners&gt;
+  &lt;/trace&gt;
+ &lt;/system.diagnostics&gt;
+ &lt;iBATIS&gt;
+  &lt;logging&gt;
+   &lt;logFactoryAdapter type="IBatisNet.Common.Logging.Impl.Log4NetLoggerFA, IBatisNet.Common.Logging.Log4Net"&gt;
+    &lt;arg key="configType" value="inline" /&gt;
+   &lt;/logFactoryAdapter&gt;
+  &lt;/logging&gt;
+ &lt;/iBATIS&gt;
+ &lt;log4net&gt;
+  &lt;appender name="FileAppender" type="log4net.Appender.FileAppender"&gt;
+   &lt;file value="log.txt" /&gt;
+   &lt;appendToFile value="true" /&gt;
+   &lt;layout type="log4net.Layout.SimpleLayout" /&gt;
+  &lt;/appender&gt;
+  &lt;root&gt;
+   &lt;level value="ALL" /&gt;
+   &lt;appender-ref ref="FileAppender" /&gt;
+  &lt;/root&gt;
+ &lt;/log4net&gt;
+&lt;/configuration&gt;</programlisting></para>
+    </sect2>
+  </sect1>
   <sect1>
     <title>The Configuration File (dao.config)</title>