Logging with Castle.Facilities.Logging and log4net

前端 未结 6 1661
轻奢々
轻奢々 2020-12-06 11:49

I\'m trying to get log4net integration for Castle Windsor working. I wrote my class with an public property of type ILogger and took the configuration in my app

6条回答
  •  失恋的感觉
    2020-12-06 12:29

    Following recent Castle conventions (correct me if wrong), I have solved it this way:

    using Castle.Facilities.Logging;
    using Castle.MicroKernel.Registration;
    using Castle.MicroKernel.SubSystems.Configuration;
    using Castle.Windsor;
    
    namespace EVRM.Aspects.Container.Installers
    {
       public class LoggingInstaller : IWindsorInstaller
        {
           public void Install(IWindsorContainer container, IConfigurationStore store)
           {
               container.AddFacility(f => f.UseLog4Net(System.AppDomain.CurrentDomain.SetupInformation.ConfigurationFile));
           }
        }
    }
    

    I have simply adapted the method provided here: http://docs.castleproject.org/Windsor.Windsor-Tutorial-Part-Five-Adding-logging-support.ashx

    and used the overload of UseLog4Net() that accepts an configuration file parameter.

提交回复
热议问题