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><configSections>
+ <sectionGroup name="iBATIS">
+ <section name="logging" type="IBatisNet.Common.Logging.ConfigurationSectionHandler, IBatisNet.Common" />
+ </sectionGroup>
+</configSections></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><iBATIS>
+ <logging>
+ <logFactoryAdapter type="IBatisNet.Common.Logging.Impl.ConsoleOutLoggerFA, IBatisNet.Common">
+ <arg key="showLogName" value="true" />
+ <arg key="showDataTime" value="true" />
+ <arg key="level" value="ALL" />
+ <arg key="dateTimeFormat" value="yyyy/MM/dd HH:mm:ss:SSS" />
+ </logFactoryAdapter>
+ </logging>
+</iBATIS>
+</programlisting><programlisting><iBATIS>
+ <logging>
+ <logFactoryAdapter type="IBatisNet.Common.Logging.Impl.NoOpLoggerFA, IBatisNet.Common" />
+ </logging>
+</iBATIS>
+</programlisting><programlisting><iBATIS>
+ <logging>
+ <logFactoryAdapter type="IBatisNet.Common.Logging.Impl.TraceLoggerFA, IBatisNet.Common" />
+ </logging>
+</iBATIS></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><iBATIS>
+ <logging>
+ <logFactoryAdapter type="IBatisNet.Common.Logging.Impl.Log4NetLoggerFA, IBatisNet.Common.Logging.Log4Net">
+ <arg key="configType" value="inline" />
+ </logFactoryAdapter>
+ </logging>
+</iBATIS></programlisting></para>
+
+ <para><programlisting><iBATIS>
+ <logging>
+ <logFactoryAdapter type="IBatisNet.Common.Logging.Impl.Log4NetLoggerFA, IBatisNet.Common.Logging.Log4Net">
+ <arg key="configType" value="file" />
+ <arg key="configFile" value="log4Net.config" />
+ </logFactoryAdapter>
+ </logging>
+</iBATIS></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><configuration>
+ <configSections>
+ <sectionGroup name="iBATIS">
+ <section name="logging" type="IBatisNet.Common.Logging.ConfigurationSectionHandler, IBatisNet.Common" />
+ </sectionGroup>
+ </configSections>
+ <iBATIS>
+ <logging>
+ <logFactoryAdapter type="IBatisNet.Common.Logging.Impl.ConsoleLoggerFA, IBatisNet.Common.Logging" />
+ </logging>
+ </iBATIS>
+</configuration></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 <log4Net> 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><configuration>
+ <configSections>
+ <sectionGroup name="iBATIS">
+ <section name="logging" type="IBatisNet.Common.Logging.ConfigurationSectionHandler, IBatisNet.Common" />
+ </sectionGroup>
+ <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
+ </configSections>
+ <appSettings>
+ <add key="log4net.Internal.Debug" value="true"/>
+ </appSettings>
+ <system.diagnostics>
+ <trace autoflush="true">
+ <listeners>
+ <add name="textWriterTraceListener"
+ type="System.Diagnostics.TextWriterTraceListener"
+ initializeData="C:\\inetpub\\wwwroot\\log4net.txt" />
+ </listeners>
+ </trace>
+ </system.diagnostics>
+ <iBATIS>
+ <logging>
+ <logFactoryAdapter type="IBatisNet.Common.Logging.Impl.Log4NetLoggerFA, IBatisNet.Common.Logging.Log4Net">
+ <arg key="configType" value="inline" />
+ </logFactoryAdapter>
+ </logging>
+ </iBATIS>
+ <log4net>
+ <appender name="FileAppender" type="log4net.Appender.FileAppender">
+ <file value="log.txt" />
+ <appendToFile value="true" />
+ <layout type="log4net.Layout.SimpleLayout" />
+ </appender>
+ <root>
+ <level value="ALL" />
+ <appender-ref ref="FileAppender" />
+ </root>
+ </log4net>
+</configuration></programlisting></para>
+ </sect2>
+ </sect1>
<sect1>
<title>The Configuration File (dao.config)</title>