Search code examples
.netloggingcastle-windsorstructuremap

Register a logger type with unique logger name


I have done this before with StructureMap and now I wish to do the same with Windsor Castle. Does anyone know how to do it?

Registry.For<ILogger>().Use(s => 
new Logger(s.ParentType ?? s.BuildStack.Current.ConcreteType));

Solution

  • Well, I got some help from a team member instead that has been using Windsor Castle.

    This is how it need to be written.

    Component.For<ILogger>().UsingFactoryMethod((m, v, i) =>
                        new Logger(i.Handler.ComponentModel.Implementation.Name)
                    ).LifeStyle.Transient