new FileInfo(
AppDomain.CurrentDomain.SetupInformation.ApplicationBase +
"log4net.config"));<iBATIS><logging><logFactoryAdapter type="IBatisNet.Common.Logging.Impl.Log4NetLoggerFA, IBatisNet.Common.Logging.Log4Net"><arg key="configType" value="external" /></logFactoryAdapter></logging></iBATIS>Now you can initialize logging from your application and let ibatis piggy back on that repository:XmlConfigurator.ConfigureAndWatch(new FileInfo( AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "log4net.config"));
>> To: mybatisnet-user@googlegroups.com
Hi Andrea, I have updated the config files the you have suggest while running i am getting error
Unrecognized element <spring> in configuration file.
so, i have commented the <spring> tag and run the application on running debug\logs folder is created with files iBatis.log & iBatisMapper.log of 0kb with no data inside.
Is there is some logging code which need to be implemented in my class file (Program.cs) for logging the ibatis executed sql.
Thanks......
On Wednesday, 13 June 2012 21:10:21 UTC+5:30, AndreaT wrote:
Hi,
this is my working configuration (running on IbatiNet.Common v1.6.2.x, log4net v1.2.10.0, Common.Logging v1.2.0, Common.Logging.Log4Net v1.2.0.2, IBatisNet.Commom.Logging. Log4Net v1.0.0.xxx)
please NOTE that <arg key="configType" value="external"/> for both common and and iBATIS sections
///////////////APP.CONFIG
<configSections>
<sectionGroup name="common">
<section name="logging" type="Common.Logging. ConfigurationSectionHandler, Common.Logging"/>
</sectionGroup>
<sectionGroup name="iBATIS">
<section name="logging" type="IBatisNet.Common. Logging. ConfigurationSectionHandler, IBatisNet.Common"/>
</sectionGroup>
</configSections>
<common>
<logging>
<factoryAdapter type="Common.Logging.Log4Net. Log4NetLoggerFactoryAdapter, Common.Logging.Log4net">
<arg key="configType" value="EXTERNAL"/>
</factoryAdapter>
</logging>
</common>
<spring>
<context>
<resource uri="file://Resources/ SpringNetMainObjects.xml"/>
<!--<section name="logging" type="IBatisNet.Common. Logging. ConfigurationSectionHandler, IBatisNet.Common" />-->
<section name="logging" type="IBatisNet.Common. Logging. ConfigurationSectionHandler, IBatisNet.Common, Version=1.6.1.0, Culture=Neutral, PublicKeyToken= ed781d9fc396c6ca" />
</sectionGroup>
<!--<section name="log4net" type="log4net.Config. Log4NetConfigurationSectionHan dler, log4net" />-->
</configSections>
<iBATIS>
<logging>
<logFactoryAdapter type="IBatisNet.Common. Logging.Impl.Log4NetLoggerFA, IBatisNet.Common.Logging. Log4Net, Version=1.6.1.0, Culture=Neutral, PublicKeyToken= ed781d9fc396c6ca">
<arg key="configType" value="file" />
<arg key="configFile" value="log4Net.config" />
</logFactoryAdapter>
</logging>
</iBATIS>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4. 0"/>
</startup>
</configuration>
log4net.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="log4net"
type="log4net.Config. Log4NetConfigurationSectionHan dler, log4net, Version=1.2.10.0, Culture=Neutral, PublicKeyToken= bf100aa01a5c2784" />
</configSections>
<log4net debug="true">
<appender name="RollingLogFileAppender"
type="log4net.Appender. RollingFileAppender, log4net, Version=1.2.10.0, Culture=Neutral, PublicKeyToken= bf100aa01a5c2784" >
<file value="ibat.txt" />
<param name="MaxSizeRollBackups" value="2" />
<param name="MaximumFileSize" value="1000KB" />
<param name="RollingStyle" value="Size" />
<param name="StaticLogFileName" value="true" />
<appendToFile value="true" />
<layout type="log4net.Layout. PatternLayout">
<param name="ConversionPattern" value="%d - %m%n" />
</layout>
</appender>
<!-- iBatis internal logging -->
<logger name="IBatisNet.DataMapper">
<level value="DEBUG" />
</logger>
<logger name="IBatisNet.DataMapper. Commands. DefaultPreparedCommand">
<level value="DEBUG" />
</logger>
<logger name="IBatisNet.DataMapper. Configuration.Cache. CacheModel">
<level value="DEBUG" />
</logger>
<logger name="IBatisNet.DataMapper. LazyLoadList">
<level value="DEBUG" />
</logger>
</log4net>
</configuration>
Program.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using IBatisNet.DataMapper;
using IBatisNet.Common;
using IBatisNet.Common.Logging;
using IBatisNet.Common.Logging.Impl;
using log4net;
namespace ConsoleApplication1
{
public class Program
{
public static ISqlMapper myMapper
{
get
{
try
{
ISqlMapper mapper = Mapper.Instance();
mapper.DataSource. ConnectionString = "Data Source=(local);Initial Catalog=testDb;Integrated Security=True";
Can you remove commons logging from the equation? I work on log4net and ibatis so you've reached the right person. Next steps would be to package up a small zip of your code somewhere so I can look through it.