Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Common.Logging with Asp.net MVC and Castle Windsor

I would like to use Common.Logging to remove dependencies on a specific logging framework, but I'm not sure how to wire up the ILog interface using the Castle Windsor IoC container. Is there a way to do this? Thanks!

like image 470
Shane Fulmer Avatar asked Dec 21 '22 20:12

Shane Fulmer


1 Answers

Do you really want to do both? (Use Common.Logging AND inject it via Castle Windsor IoC?) Using Common.Logging allows your app to NOT have a hard dependency on a specific logging framework (e.g. log4net, NLog, Enterprise Logging). I don't use Castle, but my understanding is that its logging facility has a similar goal. You can configure Castle Windsor to use a specific logging framework (such as log4net or NLog), but your application does not need to be aware of which logging framework is ultimately being used.

Injecting Common.Logging via Castle Windsor seems like wearing a belt AND suspenders to hold your pants up! You would be injecting a logging abstraction via Castle Windsor's own logging abstraction factility!

My guess is that you really want to use one technology or the other (Common.Logging or Castle Windsor's logging facility).

If you really do want to inject Common.Logging via Castle Windsor, you might find this link useful:

Logging with Castle.Facilities.Logging and log4net

Among other things, it describes how to write your own custom Castle Windsor logging facility to be injected by Castle Windsor.

like image 100
wageoghe Avatar answered Jan 07 '23 13:01

wageoghe