Log4Net Configuration From App.Config

645 views
Skip to first unread message

Maxus

unread,
May 1, 2009, 7:21:14 AM5/1/09
to Castle Project Users
Hi People,

I'm must be missing somthing, I cant get the log4net facility to take
its configuration from my App.config file, here is my config so far:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>

<configSections>
<section name="log4net"
type="log4net.Config.Log4NetConfigurationSectionHandler,log4net"/>
<section name="castle"
type="Castle.Windsor.Configuration.AppDomain.CastleSectionHandler,
Castle.Windsor"/>
</configSections>

<!-- Castle Configuration -->
<castle>
<facilities>
<facility id="loggingfacility"
configFile="RSS.KM.DataAccess.Tests.dll.config" loggingapi="log4net"
type="Castle.Facilities.Logging.LoggingFacility,
Castle.Facilities.Logging" />
<facility id="nhibernatefacility"
type="Castle.Facilities.NHibernateIntegration.NHibernateFacility,
Castle.Facilities.NHibernateIntegration" isDebug="false" isWeb="false"
useReflectionOptimizer="true">
<factory id="sessionFactory">
<settings>
<item
key="connection.provider">NHibernate.Connection.DriverConnectionProvider,
NHibernate</item>
<item
key="connection.driver_class">NHibernate.Driver.SqlClientDriver</item>
<item key="connection.connection_string">Server=
(local);Database=Test;Integrated Security=SSPI;</item>
<item key="show_sql">true</item>
<item key="dialect">NHibernate.Dialect.MsSql2005Dialect</
item>
<item key="default_schema">[Test].[dbo]</item>
<item
key="proxyfactory.factory_class">NHibernate.ByteCode.Castle.ProxyFactoryFactory,
NHibernate.ByteCode.Castle</item>
</settings>
<assemblies>
<assembly>RSS.KM.DataAccess.Tests</assembly>
<assembly>RSS.KM.DataAccess</assembly>
</assemblies>
<listeners>
<listener
type="RSS.KM.DataAccess.Common.AuditSaveOrUpdateEventListener,
RSS.KM.DataAccess" event="SaveUpdate" />
<listener
type="RSS.KM.DataAccess.Common.AuditSaveEventListener,
RSS.KM.DataAccess" event="Save" />
</listeners>
</factory>
</facility>
</facilities>
<components>
<component id="Common.Repository"
type="RSS.KM.DataAccess.Common.BaseRepository`1, RSS.KM.DataAccess" />
<component id="Common.DatabaseUtilities"
type="RSS.KM.DataAccess.Common.DatabaseUtilities, RSS.KM.DataAccess" /
>
</components>
</castle>
<!-- Castle Configuration -->

<!-- Logging Configuration -->
<log4net>
<root>
<level value="ERROR" />
<appender-ref ref="TraceAppender"/>
</root>
<appender name="TraceAppender"
type="log4net.Appender.TraceAppender">
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger
[%property{NDC}] - %message%newline" />
</layout>
</appender>
</log4net>
<!-- /Logging Configuration -->

</configuration>

I can see log4net reads its config by default from "log4net.config",
any way to to get it to read from the App.config file? (im sure im
just missing something stupid) :)

Thanks!
M

Maxus

unread,
May 1, 2009, 7:24:35 AM5/1/09
to Castle Project Users
Hi Peeps,

Sorry ignore the configFile="RSS.KM.DataAccess.Tests.dll.config" That
was just for testing.

-M
> key="proxyfactory.factory_class">NHibernate.ByteCode.Castle.ProxyFactoryFac­tory,

Roelof Blom

unread,
May 2, 2009, 5:51:07 AM5/2/09
to castle-pro...@googlegroups.com
Hi,

My guess is that the facility does not support this, you need to put the following somewhere in your application:
[assembly: log4net.Config.XmlConfigurator(Watch=true)]

-- Roelof.

Maxus

unread,
May 4, 2009, 8:32:51 PM5/4/09
to Castle Project Users
Hi Roelof,

Thanks heaps for that sugestion, I did try it earlier but it simply
didn't work for me, but now it does (Late night programming, I must
have done somthing stupid. :))

Thanks again,
-Maxus

On May 2, 5:51 pm, Roelof Blom <roelof.b...@gmail.com> wrote:
> Hi,
>
> My guess is that the facility does not support this, you need to put the
> following somewhere in your application:
>
> *[assembly: log4net.Config.XmlConfigurator(Watch=true)]*
> > key="proxyfactory.factory_class">NHibernate.ByteCode.Castle.ProxyFactoryFac­tory,
> > M- Hide quoted text -
>
> - Show quoted text -
Reply all
Reply to author
Forward
0 new messages