The LoggingFacility documentation (http://docs.castleproject.org/Windsor.Logging-Facility.ashx) states the following:
"Lets you query an instance of ILoggerFactory to support logging for classes that are not managed by Windsor."
but how can I request an instance of ILoggerFactory if my class is not managed by Windsor ??
TIA
Søren
continued:
I'm new to using Windsor (IoC), so when you say, “Why don't you have a class manager from Windsor”, I start to wonder if you say that all classes should be managed by Windsor ...
I am working on some legacy code and should create a service interface on it ... something like:
namespace RESTServer.WindsorTestService { [ServiceContract(Namespace = "urn: RESTServer_WindsorTestService:IMyServiceClass")] public interface IMyServiceClass { ILogger Logger // Will be injected by Windsor { get; set; } [OperationContract] [WebGet(UriTemplate = "MyMethod")] int MyServiceMethod(); } [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)] public class MyServiceClass : IMyServiceClass { private ILogger _logger = NullLogger.Instance; public ILogger Logger // Will be injected by Windsor { get { return _logger; } set { _logger = value; } } public int MyServiceMethod() { // ... which will populate val1, val2, val3 var val1 = 1; var val2 = 10; var val3 = 100; var myCalc = new myLegacyClass(val1, val2, val3); return myCalc.DoCalculate(1000); } } public class myLegacyClass { private int _val1; private int _val2; private int _val3; private static readonly ILog _logger = LogManager.GetLogger(typeof(myLegacyClass)); public myLegacyClass(int val1, int val2, int val3) { _val1 = val1; _val2 = val2; _val3 = val3; } public int DoCalculate(int val4) { _logger.Info("Doing some calculation"); return _val1 + _val2 + _val3; } } }
where the legacy code already uses log4net .... It works fine, but I was wondering if I need to change myLegacyClass to somehow get the logger from Windsor ... I'm just not sure what the best way .....
TIA Soren
source share