How would you resolve once and be able to access your logger across your application?

StackOverflow https://stackoverflow.com/questions/13593700

  •  02-12-2021
  •  | 
  •  

Question

Using castle windsor and the LoggingFacility, how would you resolve once and be able to use your logger across your application? I understand that bootstrapping/installing is done in global.asax and that is where the resolve should be done but I am confused about how you would access your logger outside of global.asax.

Était-ce utile?

La solution

The purpose of using Castle Windsor is to follow the Inversion of Control pattern, whereby you allow the container to inject dependencies (like the ILogger) into classes that require them. You "access the logger" by having your controllers (or whatever classes need to do logging) depend on ILogger, either by taking it as a constructor parameter, or by exposing a settable property of type ILogger.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top