Internal logs for Castle Windsor
Asked Answered
T

1

5

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.

Terrieterrier answered 2/3, 2012 at 16:53 Comment(0)
Z
4

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.

Zerelda answered 2/3, 2012 at 20:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.