You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4net-user@logging.apache.org by Ernst Kuschke <er...@gmail.com> on 2006/04/04 11:37:56 UTC
Dynamic Appenders
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