I have read through quite a few StackOverflow questions and tried multiple options. I have different databases per tenant and am trying to get a ILog with an appender for a specific database. I have successfully created an AdoNetAppender with the correct db connection string and gotten it into the log4net repository root.
However, when I ask LogManager for a new ILog, it gives me one with no appenders. If I look at the ILog instance's parent's root, it has the AdoNetAppender I added. What am I doing wrong?
Hierarchy h = (Hierarchy)LogManager.GetRepository();
var adoAppender = Log4NetAdoAppenderHelper.LoadADONetAppender(service.GetBoxDbConnectionString());
h.Root.AddAppender(adoAppender);
log4net.Config.BasicConfigurator.Configure(h);
//Neither of these work to get an appender on the ILog (_logger1 or _logger2)
var _logger1 = log4net.LogManager.GetLogger("log4net-default-repository", "AdoNetAppender");
var _logger2 = log4net.LogManager.GetRepository().GetLogger(typeof(AdoNetAppender).FullName);
Some of the StackOverflow Q/As I've looked at extensively and tried code from are: log4net - getting appenders specific to only one logger
How to configure log4net programmatically from scratch (no config)
Enable file logging for log4net from code instead of from configuration
Configure log4net RollingFileAppender in code rolling once per application start
I'm not sure why LogManager doesn't add the configured AdoNetAppender to the ILog object it gives me and am having trouble finding more on that functionality.