For something where the logger isn't used for very long, like an interceptor
- seems like you could just do something like this:

public ILoggerFactory LoggerFactory { get; set; }

public ILogger GetLogger ()
{
    string name = target.GetType().FullName + ".ExceptionInterceptor";
    return LoggerFactory.Create(name);
}

public void Blah()
{
    var logger = GetLogger();
    ...
    if (logger.IsDebugEnabled) logger.Debug(....)
}

It's not fancy - but I like the fact that the logic for naming the logger is
part of the class doing the logging, makes maintenance easier for other
developers.

On Thu, Feb 25, 2010 at 8:40 AM, bling <[email protected]> wrote:

> I'm out of ideas of how to implement this.  Basically, I wrote some
> interceptors, and they have a public property ILogger.
>
> The problem, is that sometimes I want the Interceptor name prefixed,
> and other times, suffixed.
>
> For example, if I have a ExceptionHandlingInterceptor, it's important
> that the interceptor's logger name is suffixed of the target, like:
> Full.namespace.to.impl.ExceptionInterceptor.
>
> But, for other things, like in my case, a MetricsInterceptor, it's
> more useful to have it:
> Metrics.Interceptor.ImplName
>
> That way I can filter everything for that namespace to a seperate log
> file.
>
> The best idea I've come up with so far is a combination of component
> model parameters and IOnBehalfAware, but there's probably a better/
> easier to do what I want.
>
> Any suggestions?  Thanks.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Castle Project Users" group.
> To post to this group, send email to [email protected]
> .
> To unsubscribe from this group, send email to
> [email protected]<castle-project-users%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/castle-project-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/castle-project-users?hl=en.

Reply via email to