See 
https://github.com/castleproject/Windsor/blob/master/src/Castle.Facilities.Logging/LoggerResolver.cs

On Sun, Oct 19, 2014 at 5:09 AM, Michael Powell <[email protected]> wrote:
> Hello,
>
> I imagine there's likely a simple hook for this. l have a use case, I want
> to provide a logging abstraction that dynamically deduces the type of the
> context into which a thing is injected.
>
> For instance, this is an oversimplified, somewhat contrived, example:
>
> namespace From.Whatever.Vendor //i.e. log4net
> {
>     public interface ILog
>     {
>         void Info(object message);
>
>         void Error(object message, Exception ex);
>     }
> }
>
> //TODO: and/or do this through a dynamic factory method (?)
> public interface ILogAdapter
> {
>     Type OwnerType { get; set; }
>
>     //TODO: i.e. receives LogManager.GetLogger(OwnerType.Name) based on
> owner type
>     From.Whatever.Vendor.ILog Logger { get; set; }
>
>     void Info(object message);
>
>     void Error(object message, Exception ex);
> }
>
> public interface IToBeLogged {}
>
> public class ClassImplToBeLogged : IToBeLogged
> {
>     public ILogAdapter Logger { get; set; }
> }
>
> That's a brief summary of code that illustrates the use case.
>
> What I want to be able to do is identify the owner type, through a logger
> adapter, if necessary, in such a way that I can provide the logger for the
> context in which it is injected, owning class instance, statically on
> occasion, etc.
>
> Specifically, when IToBeLogged is resolved, in this example, I want
> OwnerType to be able to reflect typeof(ClassImplToBeLogged), in order to
> provide the appropriate ILog.
>
> Doable, i.e. through factory method injection?
>
> Thanks in advance... Best regards,
>
> Michael Powell
>
> --
> You received this message because you are subscribed to the Google Groups
> "Castle Project Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/castle-project-users.
> For more options, visit https://groups.google.com/d/optout.



-- 
Cheers,
hammett
http://www.d-collab.com/
http://www.hammettblog.com/

-- 
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/castle-project-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to