Configuring log4net with ninject.extensions.logging

737 views
Skip to first unread message

Sean Chambers

unread,
Nov 14, 2009, 12:57:41 PM11/14/09
to ninject
I'm trying to get the logging extension to parse my log4net
configuration. I have it wired up and I am getting log4net instances
via the LoggerFactory in my code, but for some reason log4net isn't
parsing my config section in the web.config. Is there a trick to get
log4net to look at my configuration through the logging extension?

Here is my log4net configuration:

<log4net>

<appender name="RollingLogFileAppender"
type="log4net.Appender.RollingFileAppender">
<file value="~/Logs/" />
<appendToFile value="true" />
<datePattern value="yyyyMMdd" />
<rollingStyle value="Date" />
<filter type="log4net.Filter.LevelRangeFilter">
<acceptOnMatch value="true" />
<levelMin value="INFO" />
<levelMax value="FATAL" />
</filter>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%-5p %d %5rms %-22.22c{1}
%-18.18M - %m%n" />
</layout>
</appender>

<root>
<level value="INFO" />
<appender-ref ref="RollingLogFileAppender" />
</root>
</log4net>


Am I missing something extremely simple here? I would figure that
log4net would be able to find that since it's loaded in the
web.config.

Sean

Ian Davis

unread,
Nov 14, 2009, 1:04:19 PM11/14/09
to nin...@googlegroups.com
Did you call XmlConfigurator.Configure()? I have never done it from a web app, but that is what I do for my normal apps.

Sean Chambers

unread,
Nov 14, 2009, 1:10:27 PM11/14/09
to ninject
doh!

that got it. thanks :)

I figured that the ninject logging factory was calling that for me.

Sean

On Nov 14, 1:04 pm, Ian Davis <ian.f.da...@gmail.com> wrote:
> Did you call XmlConfigurator.Configure()? I have never done it from a web
> app, but that is what I do for my normal apps.
>

Ian Davis

unread,
Nov 14, 2009, 1:12:50 PM11/14/09
to nin...@googlegroups.com
I thought the same when I first worked with it. There are so many ways to initialize and configure log4net that we left it to the user. he idea is that Ninject will provide all of the instances and the user makes sure that they are working correctly.

Sean Chambers

unread,
Nov 14, 2009, 1:39:48 PM11/14/09
to nin...@googlegroups.com
Thanks for your help and speedy response :)


Reply all
Reply to author
Forward
0 new messages