Hi,

I am really a newbie at log4net. I want to dynamically configure loggers, and I do this as follows:

private static ILog ConfigureLogger(AuditType logType, string destination)
        {
                switch (logType)
                {
                    case(AuditType.Database):
                        appender = (AdoNetAppender)hierarchy
.GetLogger(Enum.GetName(typeof(AuditType), logType), hierarchy.LoggerFactory ).GetAppender(LOG_NAME);
                        if (appender == null)
                        {
                            appender = new AdoNetAppender();
                            //here I set some properties for the appender...
                    case(AuditType.TextFile):
                        {
                            //blah... you get the idea...
                        }
                }
                appender.Name = Enum.GetName(typeof(AuditType), logType);
                log4net.Config.BasicConfigurator.Configure(appender);
                ..........

Now how do I get the logger that uses the configured IAppender?!
Thanks in advance!!!


--
Ernst Kuschke
MVP - C#
http://dotnet.org.za/ernst

Reply via email to