Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Internal logs for Castle Windsor

How can I log Castle Windsor internal logs? For example if I had misconfigured Castle in a way that is failing to load the connection string, I want to know if I can log the errors from Castle when it tries to resolve the connection string. I'm using Log4Net Facility and I'm only able to see application logs, not Windsor logs.

like image 200
Nick Avatar asked Oct 08 '22 12:10

Nick


1 Answers

Your call to WindsorContainer.Resolve<> will throw an exception if the resolution fails. You should log this exception in your "bootstrapping" code that is responsible for creating the container and resolving the needed component(s). The exception message typically tells you exactly what is wrong in excruciating detail.

To my knowledge, Windsor does not do any "internal" logging via log4net (perhaps one of the contributors can correct/affirm this). If you wish to log "internal" events, you can hook up to the event handlers on the kernel (accessible via WindsorContainer.Kernel). For example, there are ComponentRegistered and DependencyResolving events that allow you to take custom action on registrations and resolutions, respectively.

like image 174
Stuart Lange Avatar answered Oct 12 '22 09:10

Stuart Lange