Ron Grabowski | 14 Jun 17:34

Re: Log4Net Appender

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)


Gmane