Using Autofac, I can register a class to resolve against an interface using property injection, using the following code:
builder.RegisterType
You only use logName to effectively resolve by name an ILog, so why not just inject an ILog?
public class Log4NetAdapter : ILogger
{
private readonly ILog _logger;
public Log4NetAdapter(ILog logger)
{
_logger = logger;
}
...
}
OK, so now I've just moved the problem a bit, but I've also made this less coupled to other classes, namely the LogManager.
So if I was using unity, I would then do this to ensure I get the right logger:
var childContainer = container.CreateChildContainer();
childContainer.RegisterInstance(LogManager.GetLogger(logName));
var adaptor = childContainer.Resolve();
The child container prevents any other code getting access to that ILog. You can do this as high up as you like, I don't know any more about your code.