14 Jun 17:34
Re: Log4Net Appender
From: Ron Grabowski <rongrabowski <at> yahoo.com>
Subject: Re: Log4Net Appender
Newsgroups: gmane.comp.apache.logging.log4net.devel
Date: 2008-06-14 15:37:21 GMT
Subject: Re: Log4Net Appender
Newsgroups: gmane.comp.apache.logging.log4net.devel
Date: 2008-06-14 15:37:21 GMT
By "each class that is loaded" do you mean each instance of the class needs to write to its own company database?
CompanyService companyService = new CompanyService("AlphaCompany");
CompanyService companyService = new CompanyService("BetaCompany");
CompanyService companyService = new CompanyService("GammaCompany");
If that's the case you could extend ILog and add methods that accept an identifer which would be used as the
database table:
public class CompanyService
{
private readonly static DatabaseLog log = new DatabaseLog(LogManager.GetLogger(typeof(CompanyService)));
private string companyName;
public CompanyService(string companyName)
{
this.companyName = companyName;
}
private int CalculateSomething()
{
log.Debug(companyName, "Starting to calculate something");
}
}
And/or you could create a custom AdoNetAppender that looks for a special MDC value and understands what
database table to map that to:
<appender name="CompanyAdoNetAppender">
(Continue reading)
RSS Feed