Windsor logging facility

20 views
Skip to first unread message

Flominator

unread,
Feb 10, 2009, 4:17:01 AM2/10/09
to Castle Project Users
Hi there,

yesterday I tried to implement log4net for my controllers. As expected
I ran into some problems:

1. When simply using Logger.Debug("bla bla"); the property Logger at
my controller refers to Castle.Core.Logging.NullLogger

2. When trying the suggestion from http://forum.castleproject.org/viewtopic.php?p=12187
it works. Unfortunately I've found no way to put it into my
BaseController

3. So I tried my luck with windsor: I followed
http://www.castleproject.org/monorail/documentation/trunk/integration/windsor.html
but without Castle.Model.dll (not found in trunk).

I get a compiler error at

protected void RegisterFacilities()
{
throw new Exception("dunno what to do now");
//AddFacility("rails", new RailsFacility());
}


so I commented it out and inserted an exception in order to find out,
if the method is used. I registered two controllers at Windsor:

protected void RegisterComponents()
{
AddComponent("start.controller", typeof(StartController));
AddComponent("login.controller", typeof(LoginController));
}

Everything worked fine (except the logging, but I didn't do anything
for that, yet). So I tried the hint posted at
http://mikehadlow.blogspot.com/2008/06/more-windsor-love-using-log4net.html

When I applied everything there, the exception "dunno what to do now"
was thrown. My logger at login.controller is still NullLogger.

What do I do wrong?
Does it have anything to do with 2.?
What can I do in order to make it work without having to put the code
from 2 into each and every controller?

Thanks in advance,

Flo

mausch

unread,
Feb 10, 2009, 7:17:35 AM2/10/09
to Castle Project Users
Refer to this sample app: http://svn.castleproject.org:8080/svn/castle/trunk/MonoRail/TempWeb/
In particular, see the initialization code:
http://svn.castleproject.org:8080/svn/castle/trunk/MonoRail/TempWeb/Global.asax.cs

On Feb 10, 7:17 am, Flominator <Flomina...@gmx.net> wrote:
> Hi there,
>
> yesterday I tried to implement log4net for my controllers. As expected
> I ran into some problems:
>
> 1. When simply using Logger.Debug("bla bla"); the property Logger at
> my controller refers to Castle.Core.Logging.NullLogger
>
> 2. When trying the suggestion fromhttp://forum.castleproject.org/viewtopic.php?p=12187
> it works. Unfortunately I've found no way to put it into my
> BaseController
>
> 3. So I tried my luck with windsor: I followedhttp://www.castleproject.org/monorail/documentation/trunk/integration...
> but without Castle.Model.dll (not found in trunk).
>
> I get a compiler error at
>
>                 protected void RegisterFacilities()
>                 {
>                         throw new Exception("dunno what to do now");
>                         //AddFacility("rails", new RailsFacility());
>                 }
>
> so I commented it out and inserted an exception in order to find out,
> if the method is used. I registered two controllers at Windsor:
>
>                 protected void RegisterComponents()
>                 {
>                         AddComponent("start.controller", typeof(StartController));
>                         AddComponent("login.controller", typeof(LoginController));
>                 }
>
> Everything worked fine (except the logging, but I didn't do anything
> for that, yet). So I tried the hint posted athttp://mikehadlow.blogspot.com/2008/06/more-windsor-love-using-log4ne...
Reply all
Reply to author
Forward
0 new messages