I'm new to log4net and was given a task to Switch the way log4net gets the connectionstring.
The connectionstring may be different for different groups of people who visits the site. i.e. company A has users who use the site and has its own db and therefore has its own logging table which log4net uses.
We were currently using a connection string in a webconfig file.
I created this code but doesn't work
MyNamspace
{
public class Log4NetAdoNetAppender :log4net.Appender.AdoNetAppender
{
public new string ConnectionString
{
get { return base.ConnectionString; }
set
{
base.ConnectionString = Service.GetConnectionString();
}
开发者_开发知识库 }
}
}
<appender name="ADONetAppender" type="MyNamspace.Log4NetAdoNetAppender">
I think you could:
- Configure log4net by code instead of by xml
- configure as many loggers and appenders as "connection strings"
- use the right logger to log based on the user
Hope it helps
精彩评论