PDA

View Full Version : Logging NHibernate Issue



efren.casillas
11-08-2007, 08:16 AM
Hi I am trying to configurate Spring.Net in VS 2005 but with no luck so far.

Look at the attached file to this post, it is the error generated by spring.net


This is my app.config, i dont know if its correct



<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="common">
<section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
</sectionGroup>
<sectionGroup name="spring">
<section name="context" type="Spring.Context.Support.ContextHandler, Spring.Core"/>
<section name="objects" type="Spring.Context.Support.DefaultSectionHandler, Spring.Core"/>
<section name="parsers" type="Spring.Context.Support.NamespaceParsersSectionHand ler, Spring.Core"/>
</sectionGroup>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
</configSections>
<common>
<logging>
<factoryAdapter type="Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter , Common.Logging.Log4Net">
<!-- choices are INLINE, FILE, FILE-WATCH, EXTERNAL-->
<!-- otherwise BasicConfigurer.Configure is used -->
<!-- log4net configuration file is specified with key configFile-->
<arg key="configType" value="INLINE" />
</factoryAdapter>
</logging>
</common>
<log4net>
<appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%-5level - %message%newline" />
</layout>
</appender>

<!-- Set default logging level to DEBUG -->
<root>
<level value="DEBUG" />
<appender-ref ref="ConsoleAppender" />
</root>

<!-- Set logging for MovieFinder to DEBUG -->
<logger name="ContactoProveedorDao.TestSpring">
<level value="DEBUG" />
</logger>
<logger name="Spring">
<level value="DEBUG" />
</logger>

<!-- Set logging for Spring to INFO.
Logger names in Spring correspond to the namespace -->
<logger name="Spring">
<level value="INFO" />
</logger>
</log4net>

<spring>

<context>
<resource uri="config://spring/objects"/>
</context>
<parsers>
<parser type="Spring.Data.Config.DatabaseNamespaceParser, Spring.Data" />
<parser type="Spring.Transaction.Config.TxNamespaceParser, Spring.Data" />
<parser type="Spring.Aop.Config.AopNamespaceParser, Spring.Aop" />
</parsers>
<objects xmlns="http://www.springframework.net" xmlns:db="http://www.springframework.net/database">
<db:provider id="DbProvider"
provider="MySql"
connectionString="Server=localhost:3306;Database=contacto_proveedor; User ID=root;Password=test"/>

<object id="MySessionFactory" type="Spring.Data.NHibernate.LocalSessionFactoryObject, Spring.Data.NHibernate">
<!--Add the ConnectionString-->
<property name="DbProvider" ref="DbProvider"/>

<property name="MappingAssemblies">
<list>
<value>ContactoProveedorDao</value>
</list>
</property>
<!-- Add the HibernateProperties in specify the dialect-->
<property name="HibernateProperties">
<dictionary>
<entry key="hibernate.connection.provider"
value="NHibernate.Connection.DriverConnectionProvider"/>
<entry key="hibernate.dialect"
value="NHibernate.Dialect.MySQLDialect"/>
<entry key="hibernate.connection.driver_class"
value="NHibernate.Driver.MySqlDataDriver"/>
</dictionary>
</property>
</object>

<object id="hibernateTransactionManager"
type="Spring.Data.NHibernate.HibernateTransactionManager , Spring.Data.NHibernate">
<property name="DbProvider" ref="DbProvider"/>
<property name="SessionFactory" ref="MySessionFactory"/>
</object>


<object id="genericDaoTransProxy"
type="Spring.Transaction.Interceptor.TransactionProxyFac toryObject, Spring.Data">

<property name="PlatformTransactionManager" ref="hibernateTransactionManager"/>
<property name="Target">
<object type="ContactoProveedorDao.Spring.GenericDao, ContactoProveedorDao">
<property name="SessionFactory" ref="MySessionFactory"/>
</object>
</property>

<property name="TransactionAttributes">
<name-values>
<add key="Save*" value="PROPAGATION_REQUIRED"/>
<add key="Delete*" value="PROPAGATION_REQUIRED"/>
<add key="Update*" value="PROPAGATION_REQUIRED"/>
<add key="Query*" value="PROPAGATION_REQUIRED"/>
</name-values>
</property>
</object>
<object id="HibernateTemplate" type="Spring.Data.NHibernate.HibernateTemplate">
<property name="SessionFactory" ref="MySessionFactory" />
<property name="TemplateFlushMode" value="Auto" />
<property name="CacheQueries" value="true" />
</object>
</objects>
</spring>
</configuration>

Bruno Baia
11-08-2007, 08:55 AM
Hi,

The error is explicit, it does not find NHibernate 1.0.4 in the bin directory.
Reference the NHibernate 1.0 binaries in your application.

Another error :
NHibernate 1.0.* uses log4net 1.2.9, so you need to use Common.Logging.Log4Net129 :


<factoryAdapter type="Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter , Common.Logging.Log4Net129">



HTH,
Bruno